Created
September 24, 2010 04:06
-
-
Save aussiegeek/594853 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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