CNContactPicker - User cannot select Contact after using Search

215 views Asked by At

I have an OSX app that uses CNContactPicker to import details of a single Contact that the user selects. If the user enters the Contact Picker and uses the Search bar to return a single contact (i.e. there is only one result in the list) - this contact cannot be selected. It works fine if the user search returns multiple contacts (i.e. they can select a single contact from a list of multiple contacts).

As an example: I created a Contact called "Testing". In this screenshot you will see I searched for Testing and there is 1 result in the search list. I cannot select this Contact.

enter image description here

It looks like an Apple bug to me, but I would like to know if anyone else using CNContactPicker in a Mac app has the same issue?

Here is the code:

@IBAction func importContacts(_ sender: NSButton) {
    popover = CNContactPicker()
    (popover! as! CNContactPicker).delegate = self
    (popover! as! CNContactPicker).showRelative(to: self.view.bounds, of: self.view, preferredEdge:NSRectEdge.maxX)
}

func contactPicker(_ picker: CNContactPicker, didSelect contact: CNContact) {
    importedContact = contact
}

func contactPickerDidClose(_ picker: CNContactPicker) {
    if (importedContact != nil) {
        self.populateDetailsFromContact(importedContact! as! CNContact)
    }
}

The "didSelect" delegate function does not fire in this scenario, so my "importedContact" variable is nil. I have reproduced the scenario in a small project.

0

There are 0 answers