ios - 是否可以检查联系人是否退出 iPhone 的联系人列表?
<p><p>我正在开发一个应用程序,我必须在其中将联系人保存在通讯录中,但如果联系人已经保存在联系人中,则不应保存。</p>
<p>但我不知道是否可以检查联系人是否退出 iPhone 的联系人列表?</p>
<p>任何帮助将不胜感激。</p>
<p>提前致谢。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>已解决问题</p>
<pre><code> -(void)CheckContactIsExits{
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, NULL);
NSArray *allContacts = (__bridge NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
ABRecordRef pet = ABPersonCreate();
ABRecordSetValue(pet, kABPersonFirstNameProperty, (__bridge CFStringRef)@"VoxSci Activation", nil);
for (id record in allContacts){
ABRecordRef thisContact = (__bridge ABRecordRef)record;
if (CFStringCompare(ABRecordCopyCompositeName(thisContact),
ABRecordCopyCompositeName(pet), 0) == kCFCompareEqualTo){
NSLog(@"The contact already exists");
//The contact already exists!
isContactExits=YES;
}
}
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 是否可以检查联系人是否退出 iPhone 的联系人列表?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/24160738/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/24160738/
</a>
</p>
页:
[1]