small medium large xlarge

08 Mar 2009, 07:37
Steve Fogel (20 posts)

Hi, all…

I’m trying to piece together the procedure to display a contact record from the iPhone address book when I have the first name and last name. Apple’s documentation is sketchy at best.

Is this the proper procedure?

1- Create the addressbook from the iPhone contacts database:

ABAddressBookRef iPhoneAddressBook = ABAddressBookCreate();

2-Search the addressbook with ABAddressBookCopyPeopleWithName or ABAddressBookGetPersonWithRecordID.

3-Get the returned person record (an ABRecordRef), and then pass it to an instance of ABPersonViewController

Here are some caveats:

  • An Apple support guy says that the person ID is not reliable, because it is subject to change after synchronization (I think he meant with MobileMe). So if you store an ID for a person to later look him up, you could get in trouble

  • Using ABAddressBookCopyPeopleWithName returns multiple records and may be tough to return exactly the record you want by first and last name. Any suggestions?

  • The docs say that the ABPersonViewController instance should be pushed onto a nav stack modally. Doesn’t work. My experience is you have to just push it normally.



You must be logged in to comment