Joey
Joey

Reputation: 1

Getting PFObject from Parse Relation

I have a PFRelation between Users and Offers that the User saved. Each Offer has a pointer reference to a Product PFObject. Even though I am getting the Offers saved for the particular User, the Product PFObject inside the Offer PFObject is not returning completely. Below the code I tried:

PFUser *user = [PFUser currentUser]; PFRelation *relation = [user relationForKey:@“offersSaved”]; [[relation query] includeKey:@“offersSaved.product”];

The array returned from fetch contains all the offers I want, but the offers don’t contain the product PFObjects as I would like. Any suggestions?

Upvotes: 0

Views: 29

Answers (1)

Davi Macêdo
Davi Macêdo

Reputation: 2984

try this:

PFUser *user = [PFUser currentUser];
PFRelation *relation = [user relationForKey:@“offersSaved”];
PFQuery *query = [relation query];
[query includeKey:@“product”];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    // ...
}];

Upvotes: 0

Related Questions