I am building a simple app that allows a user to login and a tableview displays the friend list.
I initially thought I would include a friends array in the PFUser class containing the ID's of the people the user is friends with. So when the app loads, the table would populate by returning the PFUser objects for those IDs using:
PFQuery *query = [PFQuery queryWithClassName:@"User"];
[query whereKey:@"id" equalTo:@"someID"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) etc..
Would it be better to create a PFRelation field and find the users from this instead on searching by the user ID? Not sure which one is faster and more efficient. Hope someone can help
Thank you
I would recommend a PFRelation field. From the Parse documentation:
In other words, the PFRelation makes more sense as you scale, especially if you conceive of individuals having lists of 100s or 1000s of friends. PFRelation is flexible and allows you to more easily query for only the friends you are seeking at the moment; for example, if you wanted to find only friends who had logged in during the past 24 hours.
Learn more here: https://www.parse.com/docs/ios_guide#objects-pointers/iOS