0

chosenCardSetObjectsis an NSMutableArray and holds a set of PFObjects.

I would like now to select data for all these given objects.

var query = PFQuery(className: "Card")
query.includeKey("cardset")

query.whereKey("cardset", equalTo: ???)

How can I pass here my chosenCardSetObjects holding all objects I want to search for?

equalTo can hold a single object, so was looking for something to hold an array and found this:

query.whereKey("cardset", containsAllObjectsInArray: chosenCardSetObjects) As ist says in the docs:

  • (instancetype)whereKey:(NSString *)key containsAllObjectsInArray:(NSArray *)array

But that returns me an error saying that: [Error]: non supported clause for pointer field cardset

Just for testing I tried:

for objectid in chosenCardSetObjects{
   query.whereKey("cardset", equalTo: objectid)
}

Which "works" for the last object in chosenCardSetObjects. But that means, my array is OK and filled correct with PFObjects, or not?

So what is the correct way of selecting my data for a list of given PFObjects? Please advice :)

2
  • The error message states that cardset is a pointer to another Parse object. What is that object? Commented Mar 19, 2015 at 15:18
  • ups, copy paste error, I need to update my code. I query from class Card which has the pointer cardset to class CardSet Commented Mar 19, 2015 at 15:27

1 Answer 1

3

You want whereKey:containedIn: I think:

query.whereKey("cardset", containedIn: chosenCardSetObjects)

This will give records where the pointer is one of the chosen cards.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, containedIn is the right way! My problem was that I defined the array as var chosenCardSetObjects: NSMutableArray! = NSMutableArray() and this method requires a NSArray.

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.