简体   繁体   中英

Can i save PFRelation with method pinInBackground?

I try save relation this way

[pfBill pinInBackgroundWithBlock:^(BOOL succeeded, NSError *PF_NULLABLE_S error)
 {
     [relation addObject:pfBill];

     [pfObjectWithRelations pinInBackgroundWithBlock:^(BOOL succeeded, NSError *PF_NULLABLE_S error)
      {
      }];
 }];

But i can't do it.

    PFRelation *relation = [[PFUser currentUser] relationForKey:@"Relation"];
PFQuery *query = [[relation query] fromLocalDataStore];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error){
    NSLog(@"%@", objects);
}];

it returns nothing, but if i save relation with saveEventually its return some objects from local datastore

Save the object and pin it on success. Until an object is saved (or pushed to saveEventually IIRC) it doesn't have an objectId and isn't considered as a 'valid' object (so you also can't add it to a relationship).

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