I'm trying to use the ABPerson
method searchElementForProperty:...
to create a moderately complex search. In particular, I want to find the set of people who have an email address that ends with "foo.com
", and are NOT part of the pre-populated group "My workunit
".
Matching against just the email address seems to be trivial. Creating a conjunction against the (inverse of the) group membership seems impossible.
Yes, I can do this by doing the obvious explicit cross-checking myself, but if the point of having search functionality directly in Address Book is to optimize performance, wouldn't it make sense for the search facility to be sufficiently complete to be able to do this?
Thanks in advance, Tony
You could potentially copy all the data from the address book into a Core Data store and use predicates to work with that data. Predicates tend to be very useful when building complex queries.
Predicate Programming Guide
In this case you would have to get all contacts (
[[AddressBook sharedAddressBook] people]
) and also have a Core Data entity calledContact
(or something similar) that would save names, emails, addresses and other properties from theABPerson
object.Having this you can probably create an
NSPredicate
to filter with the conditions you want.