Getting merged/unified entries from ABAddressBook

后端 未结 2 866
时光取名叫无心
时光取名叫无心 2020-12-23 22:18

I\'m developing an application that is showing the iPhone contacts.

The ABAddressBookRef returns duplicate entries for a contact that appears only once in the iPhon

2条回答
  •  余生分开走
    2020-12-23 23:14

    You need to have a look at a function named:

    CFArrayRef ABPersonCopyArrayOfAllLinkedPeople(ABRecordRef person);

    This function is defined in ABPerson.h. You pass in an ABRecordRef for a person and the function returns an array of ABRecordRef objects representing the address book cards that are linked to the person you passed in.

    1. Make a mutable copy of the array containing the address book entries that were returned from the ABAddressBookRef. For the sake of discussion, call this new array "finalContacts".

    2. Iterate over the original array of contacts.

    3. For each entry in the array, call the above function and pass in the current entry. You will get out a list of linked ABPersonRef objects. Remove all of these entries from the "finalContacts" array.

    4. After iteration, all linked cards should be removed from "finalContacts" and you should be left with a unique list of address book cards.

提交回复
热议问题