I need to put KeyPath values in an array of type Array<KeyPath<CNContact,Any>>. However, \CNContact.phoneNumbers fails to cast to KeyPath<CNContact,Any>.
Here is my test code:
let keyPath0: KeyPath<CNContact,Any> = \CNContact.phoneNumbers // Runtime error message: Key path value type '[CNLabeledValue<CNPhoneNumber>]' cannot be converted to contextual type 'Any'
let keyPath: KeyPath<CNContact,Any> = \CNContact.phoneNumbers as! KeyPath<CNContact,Any> // Warning message: Cast from 'KeyPath<CNContact, [CNLabeledValue<CNPhoneNumber>]>' to unrelated type 'KeyPath<CNContact, Any>' always fails