3

尝试从 PfObject 获取 PFfile 但是当我获取特定键的值时,它只给了我一个类名

这是我的云代码

Parse.Cloud.define("fetchBusinessWithID", function(request, response) {
  var query = new Parse.Query("Business");
  query.equalTo("uniqueBusinessID", request.params.businessId);
  query.find({
    success: function(results) {

      if(results.length > 0)
         {
         var fetchedObject = results[0];

         response.success(fetchedObject);
    }
    else
    {

         response.error("No Business Saved Yet");
    }



    },
    error: function() {
      response.error("Something Went wrong");
    }
  });
});

这是在 iOS 上

PFCloud callFunctionInBackground:@"fetchBusinessWithID"
                       withParameters:@{@"businessId": @"Madept2"}
                                block:^( PFObject *business, NSError *error) {

                                }];

当我在调试控制台中看到 PFObject在此处输入图像描述

那么如何获取该文件的属性,因为我无法解析 PfFile 的完整对象,请帮助我,我做错了什么。

这是我的数据模型

在此处输入图像描述

4

1 回答 1

2

通过以下方式获取您的图像数据:

PFFile *imageFile = [business objectForKey:@"aboutImage"];

[imageFile getDataInBackgroundWithBlock:^(NSData *result, NSError *error) {
    if (error == nil) {
        UIImage *aboutImage = [UIImage imageWithData:result];
        // use your image
    }
}];
于 2015-03-25T12:10:01.753 回答