Has anyone tried to display a contact with the CNContactViewController making one of the email addresses highlighted? I tried it, but if I use the highlightPropertyWithKey method, the resulting controller is blank and the following message is logged:
[CNUI ERROR] error calling service - Couldn’t communicate with a helper application.
I also tried using the deprecated API (ABPersonViewController), and the result is exactly the same. It works fine on iOS8 though.
Here's a sample code:
func openAppleSeed(highlight:Bool) {
let store = CNContactStore()
let request = CNContactFetchRequest(keysToFetch: [CNContactEmailAddressesKey]);
do {
try store.enumerateContactsWithFetchRequest(request, usingBlock: {
(contact:CNContact, stop:UnsafeMutablePointer<ObjCBool>) -> Void in
for address in contact.emailAddresses
{
if address.value as! String == "John-Appleseed@mac.com" {
do {
let fullContact = try store.unifiedContactWithIdentifier(contact.identifier, keysToFetch: [CNContactViewController.descriptorForRequiredKeys()])
let vc = CNContactViewController(forContact: fullContact)
vc.contactStore = store
if highlight {
vc.highlightPropertyWithKey(CNContactEmailAddressesKey, identifier: address.identifier)
}
self.navigationController?.pushViewController(vc, animated: true)
return
}
catch {
print("CATCHING (B)")
}
return;
}
}
})
}
catch {
print("CATCHING (A)")
}
}
Calling this function openAppleseed(highlight:false) works fine, but openAppleseed(highlight:true) generates the blank view controller and the log message mentioned aboved.
I tested it with the latest beta (5), and both simulator and device. Same result. I am submitting a bug report now, but I was curious if anyone had the same issue. Any workarounds?
Cheers.