user1555112
user1555112

Reputation: 1977

ios swift parse.com: How can I select data from multiple objects?

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 :)

Upvotes: 0

Views: 648

Answers (1)

Timothy Walters
Timothy Walters

Reputation: 16874

You want whereKey:containedIn: I think:

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

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

Upvotes: 3

Related Questions