从Device中获取联系人列表时出现问题

时间:2012-11-19 05:47:44

标签: iphone ios4 ios-simulator contacts import-contacts

此代码出了什么问题:

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";
}
)

0 个答案:

没有答案