Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't fetch parse file from PFObject

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

like image 297
Vikas Avatar asked Jan 01 '26 04:01

Vikas


1 Answers

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
    }
}];
like image 166
Wain Avatar answered Jan 03 '26 17:01

Wain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!