Get Email address from iPhone Address Book
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);
[sel开发者_开发百科f dismissModalViewControllerAnimated:YES];
return NO;
}
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];
}
精彩评论