-1

I want to batch remove custom labels from AddressBook programmatically. But there are no public API. Any one have better resolve, thanks!

Rob
  • 415,655
  • 72
  • 787
  • 1,044
林金柱
  • 13
  • 3

1 Answers1

0

Assuming you're talking about the labels associated with the emails, phones, and addresses, you would presumably

  1. Use the AddressBook.framework;
  2. Get a list of the contacts (e.g. ABAddressBookCopyArrayOfAllPeople);
  3. Iterate through the contacts;
  4. Use ABRecordCopyValue to get the ABMultiValueRef associated with multivalue properties you're interested in (e.g., possibly kABPersonEmailProperty, kABPersonAddressProperty and/or the kABPersonPhoneProperty).
  5. Use ABMultiValueGetCount to get the count of the labels;
  6. Use ABMultiValueCopyLabelAtIndex to get the actual labels;
  7. Compare those labels against kABHomeLabel, kABWorkLabel, and kABOtherLabel; and
  8. 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