ios - 如何以编程方式删除 iOS 中的多个通讯录联系人?
<p><div>
<aside class="s-notice s-notice__info post-notice js-post-notice mb16"role="status">
<div class="d-flex fd-column fw-nowrap">
<div class="d-flex fw-nowrap">
<div class="flex--item wmn0 fl1 lh-lg">
<div class="flex--item fl1 lh-lg">
<b>这个问题在这里已经有了答案</b>:
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>你可以试试这个:<br/>
你需要 <code>#import <AddressBookUI/AddressBookUI.h></code>:</p>
<pre><code>-(void) removeContactWithRecordsList:(CFArrayRef) selectedRecords_ {
ABAddressBookRef addressbook = ABAddressBookCreate();
if (selectedRecords_ != NULL)
{
int count = CFArrayGetCount(selectedRecords_);
for (int i = 0; i < count; ++i)
{
ABRecordRef contact = CFArrayGetValueAtIndex(selectedRecords_, i);
ABAddressBookRemoveRecord(addressbook, contact, nil);
}
}
ABAddressBookSave(addressbook, nil);
CFRelease(addressbook);
}
</code></pre>
<p><strong>编辑:</strong><br/>
示例:就我而言,我想删除所有名称为“Sample”的联系人</p>
<pre><code>NSString *searchName = @"Sample";
ABAddressBookRef addressbook = ABAddressBookCreate();
CFStringRef nameRef = (__bridge CFStringRef) searchName;
CFArrayRefallSearchRecords = ABAddressBookCopyPeopleWithName(addressbook, nameRef);
;
</code></pre></p>
<p style="font-size: 20px;">关于ios - 如何以编程方式删除 iOS 中的多个通讯录联系人?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/28711746/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/28711746/
</a>
</p>
页:
[1]