Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

10. Address Book > 10.7. Searching the Address Book

10.7. Searching the Address Book

Problem

You want to find a specific person or group in the address book database.

Solution

Use the ABAddressBookCopyArrayOfAllPeople and ABAddressBookCopyArrayOfAllGroups functions to find all people and groups in the address book. Traverse the returned arrays to find the information you are looking for. Alternatively, you can use the ABAddressBookCopyPeopleWithName function to find an entry about a person with a specific name.

Discussion

Up to this point, we have been inserting group and person entries into the address book without checking whether such a group or person already exists. We can use the ABAddressBookCopyArrayOfAllPeople and ABAddressBookCopyArrayOfAllGroups functions to get the array of all people and groups in the address book and search in the array to see whether the person or group entries we are about to insert into the address book already exist. When we check whether strings match, we also have to check for null strings (which we assume mean that the contacts match). Here are two methods that will make use of these functions and that can also be used in other recipes:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial