以期获取从设备的联系人列表(Issue with fetching the contacts lis

2019-08-02 21:51发布

什么不对的代码:

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";
}
)
文章来源: Issue with fetching the contacts list from Device