4

On parse.com, I have a table named "ExerciseInstance" with a "pointer" to the "_User" table (with the user's objectId).

In my Swift code, I want to get all the rows from ExerciseInstance with UserAccount<_User> = "MZmMHtobwQ"

This does not work:

predicate = NSPredicate(format:"userAccount == %@", "MZmMHtobwQ")
var query = PFQuery(className:"ExerciseInstance", predicate:predicate)

Same problem with:

var query = PFQuery(className:"ExerciseInstance")
query.whereKey("userAccount", equalTo: "MZmMHtobwQ")

Any idea - what am I missing? Best, Tom

2 Answers 2

4

You cannot check to see if it is Equal to the objectId of the user, you must create the object first:

var query = PFQuery(className:"ExerciseInstance")
query.whereKey("userAccount", equalTo: PFObject(withoutDataWithClassName:"_User", objectId:"MZmMHtobwQ"))
Sign up to request clarification or add additional context in comments.

1 Comment

Great answer! You should check out our new opening here at Parse's Platform Services Engineering team :) parse.com/jobs
0

Try this:

var teamQuery = PFQuery(className:"Team")
teamQuery.whereKey("winPct", greaterThan:0.5)
var userQuery = PFUser.query()
userQuery!.whereKey("hometown", matchesKey:"city", inQuery:teamQuery)
userQuery!.findObjectsInBackgroundWithBlock {
(results: [PFObject]?, error: NSError?) -> Void in
     if error == nil {
     // results will contain users with a hometown team with a winning record
   }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.