Issue with fetching the contacts list from Device

家住魔仙堡 提交于 2019-12-20 05:46:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!