如何从ABPeoplePicker获取用户select的电子邮件地址?

在这里的其他人Stackoverflow发布了一种方式来获取用户从联系人列表中select的电话号码。 可以做电子邮件地址,如果是的话,我该怎么做? 这里是代码:

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier { if (property == kABPersonPhoneProperty) { ABMultiValueRef multiPhones = ABRecordCopyValue(person, kABPersonPhoneProperty); for(CFIndex i = 0; i < ABMultiValueGetCount(multiPhones); i++) { if(identifier == ABMultiValueGetIdentifierAtIndex (multiPhones, i)) { CFStringRef phoneNumberRef = ABMultiValueCopyValueAtIndex(multiPhones, i); CFRelease(multiPhones); NSString *phoneNumber = (__bridge NSString *) phoneNumberRef; CFRelease(phoneNumberRef); _contactNumber.text = [NSString stringWithFormat:@"%@", phoneNumber]; } } } [self dismissViewControllerAnimated:YES completion:nil]; return NO; } 

以下是该post的链接: 如何从地址簿中获得个人电话号码?

执行如下

 - (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier { ABMultiValueRef emails = ABRecordCopyValue(person, property); CFIndex ix = ABMultiValueGetIndexForIdentifier(emails, identifier); CFStringRef email = ABMultiValueCopyValueAtIndex(emails, ix); NSLog(@"%@", email); // do something with the email here if (email) CFRelease(email); if (emails) CFRelease(emails); [self dismissViewControllerAnimated:YES completion:nil]; return NO; }