Hey
I want to get a list of all contacts of an iPhone.
I checked "Address Book" reference, I may missed something but I didn't see it provides a method to get a list of contacts.
views:
40answers:
2
+3
A:
Perhaps ABPerson
function ABAddressBookCopyArrayOfAllPeople might do?
ABAddressBookRef addressBook = ABAddressBookCreate( );
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople( addressBook );
CFIndex nPeople = ABAddressBookGetPersonCount( addressBook );
for ( int i = 0; i < nPeople; i++ )
{
ABRecordRef ref = CFArrayGetValueAtIndex( allPeople, i );
...
}
martin clayton
2010-09-19 23:19:58
Exactly thanks for your precious help. Shouldn't this functionality be part of ABAddressBook?
El Gusto
2010-09-20 00:03:40
A:
Make sure you have the proper import
#import <AddressBook/AddressBook.h>
Then you can get a CFArray object with all contacts using
CFArrayRef ABAddressBookCopyArrayOfAllPeople (ABAddressBookRef addressBook);
Hector204
2010-09-19 23:24:47