Can i save PFRelation with method pinInBackground?

103 Views Asked by At

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

1

There are 1 best solutions below

0
On

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).