On iPhone OS, how can I programmatically check if a contact exists in the address book?
-
06-07-2019 - |
Question
I've added a feature to my app that allows the user to save a business's contact details to the address book; however, to guard against adding multiple entries I want to check that the entry doesn't already exist.
Any idea how to do this? The iPhone developer documentation seems a little unclear. I'm using the C api to add the contact.
Solution
Use ABAddressBookCopyPeopleWithName() to fetch a list of potential matches from the Address Book, and then iterate through them to see if they're the name you're adding.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow