2011-01-09 128 views

回答

28

下面應該工作:

ABAddressBookRef aB = ABAddressBookCreate(); 
ABRecordRef source = ABAddressBookCopyDefaultSource(aB); // or get the source with ABPersonCopySource(somePersonsABRecordRef); 
NSArray *arr = (NSArray *)ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering(aB, source, kABPersonSortByLastName); 
// you can also use kABPersonSortByFirstName instead of kABPersonSortByLastName 
+4

注:首選排序順序ABPersonGetSortOrdering() - 這將在用戶的偏好排序順序填寫。 – n13 2012-02-01 15:57:00

0

這爲我工作:

ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, error); 
ABRecordRef source = ABAddressBookCopyDefaultSource(addressBook); 
NSArray *allPeople = (__bridge NSArray *)ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering(addressBook, source, kABPersonSortByFirstName);