Limit selections in ContactPicker Swift4

371 Views Asked by At

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?

1

There are 1 best solutions below

4
On BEST ANSWER

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])