I want to batch remove custom labels from AddressBook programmatically. But there are no public API. Any one have better resolve, thanks!
Asked
Active
Viewed 321 times
-1
-
What do you mean no public API? That is what the AddressBook framework is. – matt Jun 02 '15 at 03:01
1 Answers
0
Assuming you're talking about the labels associated with the emails, phones, and addresses, you would presumably
- Use the AddressBook.framework;
- Get a list of the contacts (e.g.
ABAddressBookCopyArrayOfAllPeople
); - Iterate through the contacts;
- Use
ABRecordCopyValue
to get theABMultiValueRef
associated with multivalue properties you're interested in (e.g., possiblykABPersonEmailProperty
,kABPersonAddressProperty
and/or thekABPersonPhoneProperty
). - Use
ABMultiValueGetCount
to get the count of the labels; - Use
ABMultiValueCopyLabelAtIndex
to get the actual labels; - Compare those labels against
kABHomeLabel
,kABWorkLabel
, andkABOtherLabel
; and - If the label doesn't match, do whatever you want with that record's particular multivalue label.
For more information, see Address Book Programming Guide for iOS: Direct Interaction: Programmatically Accessing the Database as well as the Address Book Framework Reference for iOS.

Rob
- 415,655
- 72
- 787
- 1,044