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
Post a Comment