I am using the Parse.com iOS SDK, and I don't know what method I need to call to make sure that the PFUser currentUser contains the data for each pointer contained in it. It is probably very simple, but, as a beginner with this platform, I cannot find a solution.
Just to clarify, I am trying to get the username item in the following. It looks like it is always null, even though I am calling [[PFUser currentUser] fetchIfNeeded] before proceeding:
[[[PFUser currentUser] objectForKey:@"partner"] objectForKey:@"username"];
Thank you,
Andrea
You can do it in a single query by using includeKey:
PFQuery *query = [PFUser query];
[query includeKey:@"partner"];
[query includeKey:@"anotherPointerColumnName"];
[query getObjectInBackgroundWithId:[[PFUser currentUser] objectId]
block:^(PFObject *populatedUser, NSError *error) {
PFObject *partner = populatedUser[@"partner"];
PFObject *another = populatedUser[@"anotherPointerColumnName"];
}];
You can also use deeper levels, so if partner contained a pointer in it you needed called deeperPointerColumnName:
[query includeKey:@"partner.deeperPointerColumnName"];
Then in your completion block you can read it after you get the partner:
PFObject *partner = populatedUser[@"partner"];
PFObject *deeper = partner[@"deeperPointerColumnName"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With