What's wrong with this code :
NSMutableArray* contactArray = [[NSMutableArray alloc] init];
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook); // Over here it returns zero count.
CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);
for (int i = 0 ; i < nPeople; i++) {
NSMutableDictionary* dicContact = [[[NSMutableDictionary alloc] init] autorelease];
ABRecordRef ref = CFArrayGetValueAtIndex(allPeople, i);
}
It works perfectly in Simulator but not able to get the list of contacts in Device. Where I am missing out to get the contacts from device ?
Console Output : (Simulator)
Printing description of contactArray:
<__NSArrayM 0xa13e810>(
{
City = "";
State = "";
Street = "";
ZIP = "";
email = "kate-bell@mac.com";
firstname = Kate;
lastname = Bell;
organization = "Creative Consulting";
telephone = "(555) 564-8583";
}
)
来源:https://stackoverflow.com/questions/13448345/issue-with-fetching-the-contacts-list-from-device