Reputation: 5581
To get all contacts I'm using ABAddressBookCopyArrayOfAllPeople
method but, this method return all contacts with duplicates: in "Contacts" app I saw that almost every my contacts has linked card (it's show me that I have two same contacts one from iCloud and an other from my iPad). As I see in this reason ABAddressBookCopyArrayOfAllPeople
method return duplicate contacts.
How to get all contacts from ABAddressBook without duplicate?
Upvotes: 3
Views: 3606
Reputation: 598
From memory I think this returns only one record per user:
ABRecordRef source = ABAddressBookCopyDefaultSource(addressBook);
addressBookArray = (__bridge_transfer NSArray *)ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering(addressBook, source, kABPersonSortByLastName);
I've used it an it appears to work. Although you will have to jump through the linked contacts to get all the details about a user.
Remember to CFRelease source and addressBook when you are finished.
Upvotes: 1
Reputation: 13202
I had the same problem and did not find another solution then the manual bidirectional-link-duplicate-removal process:
Two cascaded cycles (ordo n^2) that confronts the record ID of each contact-pair that was returned by ABAddressBookCopyArrayOfAllPeople
. Then I add to the final list only the contact with the smaller contact ID. It's not very beautiful solution but it works for me.
Upvotes: 0