After the last update to Xcode 5.1, the Apple's example code for sorting Address Book stopped working. URL: https://developer.apple.com/library/ios/documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Chapters/DirectInteraction.html
Example Code
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(addressBook);
CFMutableArrayRef peopleMutable = CFArrayCreateMutableCopy(
kCFAllocatorDefault,
CFArrayGetCount(people),
people
);
CFArraySortValues(
peopleMutable,
CFRangeMake(0, CFArrayGetCount(peopleMutable)),
(CFComparatorFunction) ABPersonComparePeopleByName,
(void*) ABPersonGetSortOrdering()
);
CFRelease(addressBook);
CFRelease(people);
CFRelease(peopleMutable);
But now, this code raises a warning
Cast to 'void *' from smaller integer type 'ABPersonSortOrdering' (aka 'unsigned int')
In this line
(void*) ABPersonGetSortOrdering())
How should I modified this code?
I actually looked into Apples' forums, Googled it, Stackoverflowed it, and no joy yet.
Hope you can help me.
UPDATE
It seams using 64bit has something to do with this warning. It coincide with the inclusion of the my new iPhone 5s.
ABAddressBookCreate
you should be usingABAddressBookCreateWithOptions()
. You should also be checking you have permission to access the address book beforehand withABAddressBookRequestAccessWithCompletion
too. See here for more details... #12084143 – IntraatomicABAddressBookCreateWithOptions
for creating the address book. – Decorticate