Pulling data from Address Book

Discussion in 'iOS Programming' started by ataylor2009, Jun 12, 2009.

  1. ataylor2009 macrumors member

    Joined:
    Jan 27, 2009
    #1
    I have read the Address Book Programming Guide from Apple, but the examples therein don't quite go far enough to answer my question before referring the reader to the arcane framework references.

    I would like to allow users to select a property within an address book record. I can present the ABPeoplePickerNavigationController, return YES to peoplePickerNavigationController: shouldContinueAfterSelectingPerson:, and then, within my implementation of peoplePickerNavigationController: shouldContinueAfterSelectingPerson: property: identifier:, I start to lose it.

    I have three variables I'd like to set based on address book record properties: name (ABRecordCopyCompositeName), numberLabel (the label for the selected phone number, i.e. "work" or "home"), and the number itself (i.e. the selected telephone number).

    I think I'm okay on the name, but the numberLabel and the number - both of which are part of a multiproperty value, are baffling. How do you find out what number was selected and get its corresponding label?

    As ever, thanks in advance for your advice.
     
  2. ataylor2009 thread starter macrumors member

    Joined:
    Jan 27, 2009
    #2
    After a long hiatus, I am back on the prowl for this information so I can finish building my app. I can get to the peoplePicker display; once my user selects a person, I can present the address book record. When my user selects a phone number, though, I lose it...I am for some reason unable to wrap my head around actually getting and using the data my user just selected.

    What I need are the record ID, the composite name, and the label and value of the phone number my user just selected. Apple's Address Book Programming Guide gives sort of a 50,000-foot overview of the process, but doesn't provide enough example code for me to make sense of the procedure.

    Anyone who can point me in the right direction will be my new favorite person. Thanks in advance.
     
  3. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #3
    you need to provide a delegate for the people picker and implement the following method

    Code:
    peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier:
    
    http://tinyurl.com/yfjuppo -reference

    http://tinyurl.com/blrndd -code example
     
  4. ataylor2009 thread starter macrumors member

    Joined:
    Jan 27, 2009
    #4
    Thanks for the help. Isn't that code snipped pulling values from a whole list of multivalue properties, though? Does the peoplePickerNavigationController not return JUST the selected person/property/value when said value is selected? I.e., if my user selects "David Taylor > iPhone (212) 555-1212," does the controller not just return those three values?

    Or do I have to go through the whole "set up an array, copy the whole list of multivalues, get the identifier of the selected item," etc?

    Thanks again for your help.
     
  5. ataylor2009 thread starter macrumors member

    Joined:
    Jan 27, 2009
    #5
    Okay - the code sample you posted above works (actually, a reader's comments containing modified code below the code sample worked). Thanks for the tip; it's awesome to be able to come here and get help when I get stumped.

    The only problem I'm having is that, seemingly randomly, the data (specifically the phone label property) is sometimes formatted as "iPhone" and sometimes formatted as "_$!<iPhone>!$_" or similar. So far I can't figure out any kind of pattern as to when it's one way and when it's another. Any ideas?
     

Share This Page