I have an array of Address Book contact dictionaries, with the dictionary for each name containing a string for the name and an array of email addresses. Here's a snippet of what the NSLog output looks like when I log the array of contacts:
{
emails = (
"[email protected]"
);
name = "Some Name";
},
{
emails = (
"[email protected]",
"[email protected]"
);
name = "John Q. Public";
},
[etc.]
I want to use a predicate to search these dictionaries by email address, returning any and all entries that have at least one email address that matches the search term.
So far, I have tried the method described in this question, just using CONTAINS, like so:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"emails CONTAINS[c] %@", searchString];
but any search just returned an empty array. If I search the name field instead, like so, it works fine:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name CONTAINS[c] %@", searchString];
So I'm pretty sure it's specifically with searching the array. Ideas?