Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTony Li
589 PointsHow to get PFuser if I only have user's objectId
I am using Parse for my backend. I only query user's objectId, but I want to get PFuser to do the PFRelation thing. How to get PFuser if I only have user's objectId. Or how to get PFuser from PFObject.Can somebody help me ?
1 Answer
John W
21,558 PointsThe end of the querying section of the documentation mentions a method called getUserObjectWithId:objectId:
https://parse.com/docs/ios_guide#users-querying/iOS
You can also query the objectId just like any other column:
PFQuery * query = [PFUser query];
[query whereKey:@"objectId" equalTo:@"A1B2Z3XX"];
NSArray * results = [query findObjects];
Tony Li
589 PointsTony Li
589 PointsBut every time I use getUserObjectWithId:objectId: it tells me : Warning: A long-running Parse operation is being executed on the main thread. Break on warnParseOperationOnMainThread() to debug.
Ben Jakuben
Treehouse TeacherBen Jakuben
Treehouse TeacherIf you switch to one of the "inBackground" methods, like findObjectsInBackgroundWithBlock, then this warning should disappear. Any request to Parse (any network request at all for that matter) is considered a "long-running operation" and should be executed in the background one way or another. Using the regular version of
findObjects
executes it normally on the main thread of the app, which should be as responsive as possible.