CKQuery predicate fails with ANY-BEGINSWITH

Reading the CKQuery documentation, I found this example:

[NSPredicate predicateWithFormat:@"ANY favoriteColors BEGINSWITH %@", matchString]

If favoriteColors is a String List, that means that I can search for the beginning of each value in the string list, however if I tried this, the app crashes.

Terminating app due to uncaught exception 'CKException', reason: 'Invalid predicate: ANY nameSearch BEGINSWITH "Do"

In my test, nameSearch is a String List.

I don't know if I'm understand the documentation wrong and favoriteColors is not a string list, but then why they are using ANY?

Replies

Do you have a Searchable index on favoriteColors?

  • I was using BEGINSWITH, it shouldn't need to be Searchable. My whole idea was being able to search for prefixes in an array containing words.

    Searchable was not an option because I needed to search by prefixes, like if you are looking for all the "Joels", so I can start searching for "J", "Jo", "Joe" and find what I'm looking for.

    I decided change my idea, and I'm going to synchronize to the device, so I can use coredata to make best queries.

Add a Comment