什么不对的代码:
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);
}
它完美的模拟器,但没能获得在设备的联系人列表。 当我错过了获得从设备的联系人?
控制台输出:(模拟器)
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";
}
)