swift4 - Swift 4 KVC - Cast to unrelated type always fail -


i not able conditional cast keypath related object keypath superclass. have easy setup

class foo {     let name: string     init(name: string) {         self.name = name     } } class bar: foo {}  let keypath = \bar.name if let keypath = keypath as? keypath<foo, string> {     print(keypath) } 

it's giving me warning print method never executed because

cast 'keypath<bar, string>' unrelated type 'keypath<foo, string>' fails

generally speaking want able operate anyobject inside keypath behaviour preventing me doing that. can explain how downcasting works keypath , perhaps offer way around?


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -