简体   繁体   English

ABAddressBookCopyArrayOfAllPeople无法获取存储在SIM卡上的联系人

[英]ABAddressBookCopyArrayOfAllPeople not getting contacts stored on SIM Card

I'm using the code provided from the accepted answer at Retrieve all contacts phone numbers in iOS and I've noticed a lot of contacts are missing. 我正在使用从iOS上的“ 检索所有联系人电话号码”中的可接受答案提供的代码,我注意到很多联系人都丢失了。 I'm pretty sure they're contacts stored on the SIM card and somehow ABAddressBookCopyArrayOfAllPeople doesn't retrieve contacts from the SIM card. 我很确定他们是存储在SIM卡中的联系人,并且ABAddressBookCopyArrayOfAllPeople以某种方式不会从SIM卡中检索联系人。 If I use ABPeoplePickerNavigationController the contacts do appear, but that isn't suitable for what I'm building. 如果我使用ABPeoplePickerNavigationController则确实会出现联系人,但这不适合我要构建的对象。

Does anyone know how to overcome this issue? 有谁知道如何克服这个问题?

Thanks 谢谢

Missing contacts in ABAddressBookCopyArrayOfAllPeople had the answer. ABAddressBookCopyArrayOfAllPeople中缺少联系人的答案。 Although it wasn't entirely clear at first what the poster did, the main thing was casting the ABMultiValueRef to an NSArray like so: 尽管起初并不清楚海报的​​功能,但主要是将ABMultiValueRef转换为NSArray如下所示:

ABMultiValueRef phones = (__bridge ABMultiValueRef)((__bridge NSString*)ABRecordCopyValue(ref, kABPersonPhoneProperty));
NSArray *phoneNumbers = (__bridge NSArray *)ABMultiValueCopyArrayOfAllValues(phones);

After that phoneNumbers contains every phone number for the current ABPerson . 之后, phoneNumbers包含当前ABPerson每个电话号码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM