Created
February 6, 2010 11:52
-
-
Save nestserau/296671 to your computer and use it in GitHub Desktop.
Picking an email address from Address Book with no fail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *) | |
peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person | |
property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier { | |
ABMultiValueRef emails = ABRecordCopyValue(person, property); | |
CFStringRef email = ABMultiValueCopyValueAtIndex(emails, identifier); | |
NSString *str = [textField text]; | |
if (![str isEqualToString:@""]) { | |
str = [NSString stringWithFormat:@"%@, %@", str, email]; | |
} else { | |
str = (NSString *)email; | |
} | |
[textField setText:str]; | |
[controller dismissModalViewControllerAnimated:YES]; | |
return NO; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *) | |
peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person | |
property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier { | |
ABMultiValueRef emails = ABRecordCopyValue(person, property); | |
NSArray *emailArray = [(id)ABMultiValueCopyArrayOfAllValues(emails) | |
autorelease]; | |
const NSUInteger emailIndex = ABMultiValueGetIndexForIdentifier(emails, | |
identifier); | |
NSString *email = [emailArray objectAtIndex:emailIndex]; | |
NSString *str = [textField text]; | |
if (![str isEqualToString:@""]) { | |
str = [NSString stringWithFormat:@"%@, %@", str, email]; | |
} else { | |
str = (NSString *)email; | |
} | |
[textField setText:str]; | |
[controller dismissModalViewControllerAnimated:YES]; | |
return NO; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment