简体   繁体   中英

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?

try this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM