1

I have a contact with linked contacts. So when I show this contact with ABPersonViewController is has original emails and emails from linked contacts. enter image description here

When I select linked email (John-appleseed@mac.com) then delegate method calls:

- (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
    //get selected phone number
    ABMultiValueRef multi = ABRecordCopyValue(person, property);
    CFIndex index = ABMultiValueGetIndexForIdentifier(multi, identifier);
    NSString *selectedContactData = (__bridge_transfer NSString *)ABMultiValueCopyValueAtIndex(multi, index);

    return NO;
}

But in selectedContactData I get not selected email, but first one. I have this problem only with combined contacts.

Is there a proper way to choose email from contact with connected contacts?

Kirill Pyulzyu
  • 381
  • 2
  • 11

1 Answers1

1

The only way I can imagine the behavior you describe is that you might be referencing a ABRecordRef in some property or ivar that you populated when you first populated displayedPerson property for the ABPersonViewController. Clearly, in this code snippet you are correctly using the person property that was passed to this delegate method, but perhaps you simplified the code snippet when sharing it with us? When I use your code snippet with shouldShowLinkedPeople turned on, it works fine for me for a linked contact's properties.

If you're sure you don't have an issue with using the wrong ABRecordRef variable, the only other possibility I can imagine is that I have experienced strange behavior using the default contacts that are provided on the simulator. I might suggest trying this on an actual device with real linked contacts.

Rob
  • 415,655
  • 72
  • 787
  • 1,044