6
有沒有人有如何正確設置參數的代碼示例,並使用ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering()API來獲取iPhone聯繫人列表的排序子集?ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering的代碼示例?
有沒有人有如何正確設置參數的代碼示例,並使用ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering()API來獲取iPhone聯繫人列表的排序子集?ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering的代碼示例?
下面應該工作:
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
這爲我工作:
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, error);
ABRecordRef source = ABAddressBookCopyDefaultSource(addressBook);
NSArray *allPeople = (__bridge NSArray *)ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering(addressBook, source, kABPersonSortByFirstName);
注:首選排序順序ABPersonGetSortOrdering() - 這將在用戶的偏好排序順序填寫。 – n13 2012-02-01 15:57:00