I'm using a CNContactPickerViewController to let the user select the email of one of his/her contacts
let contactPicker = CNContactPickerViewController()
contactPicker.delegate = self
contactPicker.predicateForSelectionOfContact = NSPredicate(format: "emailAddresses.@count > 0")
contactPicker.displayedPropertyKeys = [CNContactNicknameKey, CNContactEmailAddressesKey]
When the contact has only one mail, everything goes well
func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact) {
if let _mail = contact.emailAddresses.first?.value as String? {
self.personWasSelected(with: _mail)
}
}
But sometimes one of the contacts has more than one mail, how can I let the user select on one of those?
Ok, found the solution by trial-error...
I was implementing both:
But only the first one should have been implemented