0

I'm trying to get started using YapDatabase, mostly to see if it's worth replacing some NSPredicate-based searches I've been using for a while. One search I can't seem to find a good way of doing so far with SQLite queries is finding all objects with where an array property of the object includes any matches with a given search array.

For example, say I have an array of birds, each of which has an array of state names where the bird is found. To search for all birds that are found in a group of states, I would use this predicate filter:

  NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY %@ IN foundInStates", arrayOfStates];
  return [_myBirdDatabase filteredArrayUsingPredicate:predicate];

I guess I could make a very convoluted SQLite query involving many "LIKE" operators, but I'm hoping there's a way that's as clean as the NSPredicate search.

RL2000
  • 913
  • 10
  • 20
  • 1
    Show how the data is stored in SQLite (which does not have an array type). – CL. Nov 27 '17 at 08:43
  • @CL. thanks... that probably points to my lack of understanding of SQLite ;-) I guess what I should be doing is converting the array of strings to a string with a specific delimiter, and search using LIKE operators. I was assuming that YapDatabase (the SQLite wrapper) had something going on for arrays. – RL2000 Nov 27 '17 at 17:23

0 Answers0