Skip to content

Instantly share code, notes, and snippets.

@aussiegeek
Created September 24, 2010 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aussiegeek/594853 to your computer and use it in GitHub Desktop.
Save aussiegeek/594853 to your computer and use it in GitHub Desktop.
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(addressBook);
CFMutableArrayRef peopleMutable = CFArrayCreateMutableCopy(
kCFAllocatorDefault,
CFArrayGetCount(people),
people
);
CFRelease(people);
CFArraySortValues(
peopleMutable,
CFRangeMake(0, CFArrayGetCount(peopleMutable)),
(CFComparatorFunction) ABPersonComparePeopleByName,
(void*) ABPersonGetSortOrdering()
);
for (int i = 0; i < CFArrayGetCount(peopleMutable); i++) {
ABRecordRef abrecord = CFArrayGetValueAtIndex(peopleMutable, i);
// code that expects the ABRecordRef to actually be valid
}
CFRelease(addressBook);
CFRelease(peopleMutable);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment