How to receive email from selected ABPerson in ABPeoplePickerView

I need to access the email of the selected person from my Cocoa application. I placed ABPeoplePickerView in the main window and got a list of favorites through [peoplePicker selectedRecords]. How to access the email field of an object ABPerson?

+3
source share
2 answers
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker 
     shouldContinueAfterSelectingPerson:(ABRecordRef)person 
                               property:(ABPropertyID)property 
                             identifier:(ABMultiValueIdentifier)identifier
{
    NSString *email = nil;
    ABMultiValueRef emails = ABRecordCopyValue(person, kABPersonEmailProperty);
    if(emails){
        email = (NSString *) ABMultiValueCopyValueAtIndex(emails,0);
        [email autorelease];
    }

    [self dismissModalViewControllerAnimated:YES];
    emaillabel.text = email;
    return YES;
}
+2
source

I assume your object ABPersonrefers to person:

ABRecordCopyValue( ( ABRecordRef ) person, kABEmailProperty );
0
source

Source: https://habr.com/ru/post/1794969/


All Articles