I'm using the predicates defined here: How can I pick a contact phone number in iOS?.
contactsPicker.predicateForEnablingContact = NSPredicate(format:"phoneNumbers.@count > 0")
contactsPicker.predicateForSelectionOfContact = NSPredicate(format: "phoneNumbers.@count == 1")
contactsPicker.displayedPropertyKeys = [CNContactPhoneNumbersKey]
I have also defined the following delegate methods:
func contactPicker(_ picker: CNContactPickerViewController,
didSelect contactProperty: CNContactProperty) {
print(contactProperty)
}
func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact) {
print(contact)
}
The behaviour I expect is that the user gets to pick the phone number properties from multiple different contacts and when the user clicks done, I get a list of these properties and contacts.
Unfortunately, the code above exits the picker immediately when the user clicks done. This means the user cannot select multiple phone numbers and/or multiple contacts and can only select one before the picker exits.
How can I change it so that it selects multiple properties or contacts and submits on clicking on done?