pasine
pasine

Reputation: 11543

Filter contacts in iphone address book

I've created an address book copy with

ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(addressBook);
CFMutableArrayRef peopleMutable = CFArrayCreateMutableCopy(
                                                           kCFAllocatorDefault,
                                                           CFArrayGetCount(people),
                                                           people
                                                           );

now i would have just people with an address set in.

I've tried filtering with NSPredicate, but I don't know how to use the predicateWithFormat correctly with address book constants. This doesn't work:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(%@ like %@)", kABPersonFirstNameProperty, aVariable];

Can someone suggest me something? Thanks

Upvotes: 2

Views: 3026

Answers (1)

Josh Bleecher Snyder
Josh Bleecher Snyder

Reputation: 8432

Take a look at http://github.com/erica/ABContactHelper -- if it doesn't have code that does what you want already, it should be a useful guide for writing it yourself.

Upvotes: 7

Related Questions