Get iPhone address book contacts in iphone application
I have an iphone applicat开发者_高级运维ion.Within which I want to get all the iphone address book contacts in an array.
Is that possible?
Yes. ABAddressBook is what you want.
Looks like it:
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);
for( int i = 0 ; i < nPeople ; i++ ) {
ABRecordRef ref = CFArrayGetValueAtIndex(allPeople, i );
NSLog(@"inside loop");
}
精彩评论