当我选择具有多个电话号码的联系人并选择他们的一个电话号码时,这很好用,recipientAddress 设置为所选电话号码。但是,当我从具有多个电子邮件地址的联系人中选择电子邮件地址时,ABMultiValueIdentifier 为零,它转换为索引为零,这始终是联系人中的最后一封电子邮件,无论我选择了哪一个。
我一定是做错了很尴尬的事情,而且很容易被发现,所以请通过暴露我的愚蠢来让自己看起来很棒。
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
@try {
[eta addRecipient: person : property: identifier];
}
@catch (NSException *exception) {
errExcLog(exception);
}
return NO;
}
- (void) addRecipient : (ABRecordRef) person : (ABPropertyID) property : (ABMultiValueIdentifier)identifier {
ABMultiValueRef mvPropertyRef = ABRecordCopyValue(person, property);
int propertyIndex = ABMultiValueGetIndexForIdentifier( mvPropertyRef, identifier);
NSString *recipientAddress = (__bridge NSString *)(ABMultiValueCopyValueAtIndex( mvPropertyRef, propertyIndex));
}