views:

494

answers:

1

I am currently able to successfully access and get data from the peoplePickerNavigationController, but what I would like to do is have the email address of the contact be accessed, then the modal window dismissed when the contact name is pressed.

Scenario:

"Button is clicked to add a contact
AddressBook Modal Window slides into view
Name of Contact is pressed
If available, the contact's email address is stored in an array
Dismiss modal window"

My current code consists of:

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
    ABMultiValueRef container = ABRecordCopyValue(person, property);
    CFStringRef contactData = ABMultiValueCopyValueAtIndex(container, identifier);
    CFRelease(container);
    NSString *contactString = [NSString stringWithString:(NSString *)contactData];
    CFRelease(contactData);

    NSLog(@"Value is: %@", contactString);

    [self dismissModalViewControllerAnimated:YES]; 
    return NO;
}
A: 

Here is what i do.

if(property == kABPersonEmailProperty) {
  CFTypeRef prop = ABRecordCopyValue(person, property);
  CFIndex index = ABMultiValueGetIndexForIdentifier(prop,  identifierForValue);
  NSString *email = (NSString *)ABMultiValueCopyValueAtIndex(prop, index);

  ...

  CFRelease(prop);
  [email release];
}
John Stallings
now do I put this in the `peoplePickerNavigationController: shouldContinueAfterSelectingPerson: property: identifier:` method? Because this is doing the same thing the code I supplied does...
rson
sorry, yes that needs to be in the method, then if you opened the PeoplePicker modally you need to dismiss it as you have above.
John Stallings