Is it possible to access an object's superclass's property using key-value coding?
I tried something like this:
class Bar: Foo {
var shouldOverridePropertyOfFoo: Bool = false
var propertyOfFoo: String {
if shouldOverrideProperty {
return "property of Bar"
} else {
return value(forKeyPath: "super.propertyOfFoo") as! String
}
}
}
But, I got this runtime error:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '
[<MyModule.Bar 0x2da2cf003e00> valueForUndefinedKey:]
: this class is not key value coding-compliant for the keysuper
.'
Note: I'm trying to figure out how to override private method and call super in swift?