gpt4 book ai didi

iPhone地址簿: How to get a list of only contacts with phone numbers?

转载 作者:行者123 更新时间:2023-12-03 19:06:08 26 4
gpt4 key购买 nike

我想获取所有具有电话号码的 ABContacts 的列表,并且仅获取这些联系人。我不想显示任何仅包含电子邮件的联系人。

Android 有一个名为 HAS_PHNONE_NUMBER 的字段,您可以查询该字段,但我没有在 iPhone 上看到类似的字段。

例如:

ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(addressBook);
//How do I filter people into an array of contacts that all have a phone number?

最佳答案

您可以使用此代码片段

CFIndex numberOfPeople = CFArrayGetCount(_allPeople);
for (int i=0;i < numberOfPeople;++i) {
ABRecordRef ref = CFArrayGetValueAtIndex(_allPeople, i);
ABMultiValueRef phones =(NSString*)ABRecordCopyValue(ref, kABPersonPhoneProperty);
int phoneNumbersCount = ABMultiValueGetCount(phones);
if (phoneNumbersCount>0)
{
// save this contact, it has phone number
}
}

关于iPhone地址簿: How to get a list of only contacts with phone numbers?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5352938/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com