Reputation: 9466
I'm trying to capture the given name of a contact when the user selects that contact from the Contact Picker. Right now I'm using this method
func contactPicker(_: CNContactPickerViewController, didSelect: CNContact){
print("Selected Contact")
}
It works but I don't see how I can get a reference to the contact object that was selected. I was trying to reference these properties CNContact
Upvotes: 0
Views: 223
Reputation: 1003
The second parameter is the selected CNContact
object. Note the contact
next to the didSelect
which is missing in your example. In your example you have to use didSelect
parameter which is your CNContact
but contact would be a much more expressive name.
func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact) {
print(contact.givenName)
}
Upvotes: 2