3

Trying to fetch a PFfile from PfObject but when I fetch value of a particular key , it only gives me a class name

Here is my CloudCode

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");
    }
  });
});

And this is on iOS

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

                                }];

When I see PFObject in Debug consoleenter image description here

So how can I fetch attributes of this file, as I can not parse full object of PfFile, Please help me on this, What I am doing wrong.

Here is my data Model

enter image description here

Vikas
  • 914
  • 7
  • 19
  • So your business class has a reference to yhe PFFile? Stored in the aboutImage key? Have you written any code to use the file (download it)? – Wain Mar 25 '15 at 07:57
  • I will download that ,once i get image url, But i can't get any property of PFFIle Object – Vikas Mar 25 '15 at 07:59
  • the PFFile is the image data, it doesn't provide a URL to the image data. the file itself has a URL but you generally use the PFFile API to get the data – Wain Mar 25 '15 at 09:24
  • @Wain But I should atleast have a PFfile Object to call any Api, How will I download data unless I am not having any PFfile instance – Vikas Mar 25 '15 at 09:43
  • How can I get PFFile instance – Vikas Mar 25 '15 at 11:06
  • What is your data model in parse.com ? – Wain Mar 25 '15 at 11:52
  • @Wain Edited my question with data model screenshot, thanks for providing all the support, Please help me on this, I urgently need this to be working. – Vikas Mar 25 '15 at 12:05

1 Answers1

2

Get your image data with:

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

[imageFile getDataInBackgroundWithBlock:^(NSData *result, NSError *error) {
    if (error == nil) {
        UIImage *aboutImage = [UIImage imageWithData:result];
        // use your image
    }
}];
Wain
  • 118,658
  • 15
  • 128
  • 151