So moving from Address book to Contacts, and watching the video https://developer.apple.com/videos/wwdc/2015/?id=223
I found a few things missing.
I just want to display my contacts that have one or more email addresses. So I use:
let contactPicker = CNContactPickerViewController()
contactPicker.displayedPropertyKeys = [CNContactEmailAddressesKey]
contactPicker.predicateForEnablingContact = NSPredicate(format: "emailAddresses.@count > 0")
contactPicker.predicateForSelectionOfContact = NSPredicate(format: "emailAddresses.@count == 1")
contactPicker.delegate = self
self.presentViewController(contactPicker, animated: true, completion: nil)
First in the video they do not show but I'm assuming we have to impliment the CNContactPickerDelegate.
Next I have the following method to catch the selection of the contact email:
func contactPicker(picker: CNContactPickerViewController, didSelectContactProperty contactProperty: CNContactProperty) {
print(contactProperty.contact)
}
When the Contacts are initially displayed, I get this
#1
2015-07-25 13:42:12.448 [1327:453453] [CNUI ERROR] Person selection predicate is set but the delegate does not implement contactPicker:didSelectContact:. The predicate will be ignored.
Not sure why.
The real question is when I select one of the emails in the contact card, the device goes blank and in the log I get:
#2
2015-07-25 13:44:10.521 [1327:454336] plugin com.apple.MobileAddressBook.ContactsViewService interrupted
2015-07-25 13:44:10.523 [1327:454336] plugin com.apple.MobileAddressBook.ContactsViewService invalidated
2015-07-25 13:44:10.540 [1327:453453] viewServiceDidTerminateWithError:: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}