Using NSPredicate for PFQuery Effective


My app is using Parse as a back end. At some point in the app, i have to query objects that should contain at least one of the tags in another array. To make it clear, in the database i have a class Pictures which has a Tags property that saves tags in an array. In my app, i have an array of tags that i need to compare with. Only the objects that has at least one of the tags stored in the Tags property should be fetched. I tried to using the following PFQuery functions whereKey:containedIn: and whereKey:containsAllObjectsInArray: however none of them does what i want. Now i shifted my attention to NSPredicates. I tried the following:

PFQuery *postsQuery = [PFQuery queryWithClassName:@"Pictures" predicate:[NSPredicate predicateWithFormat:@"ANY Tags MATCHES ANY ", _tags]];

When i run the code i receive the following error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "ANY Tags MATCHES ANY "'

How can i perform such a query or the right NSPredicate for my situation?

As an illustration on what the query should be about for further explanation: let's say one of the objects in the database has the following in the "Tags" column

Tags = ["music", "video", "picture", "chocolate"]

and the tag array that i want to use in predicate is the following:

tagsArray = @["picture", "French"];

what i'm expecting is receiving the previous object because it has the "picture" tag. If another object doesn't contain at least one of the tags in the tagsArray it shouldn't be fetched.

Edite: I found out that i can't use Aggregate Operations such as ANY, SOME, ALL, or NONE. could i find another solution?

The other solution is to use cloud code and write the query on the server in Javascript.

Then you just access the new API endpoint that you defined and get the results of the query that way.