此代码出了什么问题:
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);
}
它在Simulator中完美运行但无法获取Device中的联系人列表。 我错过了从设备获取联系人的地方?
控制台输出:(模拟器)
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";
}
)