I am using ContactsUI to have a user select contacts. Everything works properly but I would like to limit the number of contacts that can be selected. Is this possible?
Asked
Active
Viewed 321 times
1 Answers
4
No. You can limit which contacts are selectable, and you can limit whether one or multiple contacts can be selected, but if you choose multiple, that means "as many as the user likes".
How is the determination between one selection vs. multiple made? It all depends on what delegate methods you implement. If you want to limit the user to just one selection, implement this delegate method:
func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact)
Do not implement this method:
func contactPicker(_ picker: CNContactPickerViewController, didSelect contacts: [CNContact])

matt
- 515,959
- 87
- 875
- 1,141
-
Oh okay that makes sense. So how can I limit the user to just one selection? – Mark Tamotsu Kinoshita Aug 10 '18 at 23:23
-
Implement this delegate method: `contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact)` Do _not_ implement this method: `contactPicker(_ picker: CNContactPickerViewController, didSelect contacts: [CNContact])` – matt Aug 10 '18 at 23:29
-
Thank you this solved my problem and lead to a couple other realizations. Thanks for the help! – Mark Tamotsu Kinoshita Aug 11 '18 at 00:12
-
Delighted to hear this made the lightbulb come on! :) – matt Aug 11 '18 at 00:35