Question

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;
}
Was it helpful?

Solution

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];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top