안녕하세요 저는 tableview에서 모든 주소록 연락처를 표시해야합니다. 사용자가 여러 연락처를 선택하려면 선택한 연락처를 삭제하십시오. 이에 대한 해결책을 찾지 못했습니다.
이것을 시도해 볼
수 있습니다 #import <AddressBookUI/AddressBookUI.h>
.
-(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);
}
편집 :
예 : 내 경우에는 모든 연락처를 "Sample"이라는 이름으로 제거하고 싶습니다.
NSString *searchName = @"Sample";
ABAddressBookRef addressbook = ABAddressBookCreate();
CFStringRef nameRef = (__bridge CFStringRef) searchName;
CFArrayRef allSearchRecords = ABAddressBookCopyPeopleWithName(addressbook, nameRef);
[self removeContactWithRecordsList:allSearchRecords];
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다