考虑这个简单的方法:
- (void)connectSpouseToCurrentUser:(PFUser *)spouse completionBlock:(void (^)(NSError *error))completionBlock {
[PFUser currentUser][@"spouse"] = spouse;
[[PFUser currentUser] saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (error) {
NSLog(@"Error: %@", [error userInfo]);
}
spouse[@"spouse"] = [PFUser currentUser];
[spouse saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
// This code never executes
NSLog(@"Error: %@", error);
self.spouse = spouse;
if (completionBlock) {
completionBlock(error);
}
}];
}];
}
由于某些原因,我最新的完成块没有被调用。
有谁知道为什么会这样?