I am trying to understand latest addition to Swift 4 - better KVC. Having this simple stuff in playground prints out nothing
class Foo {
var name: String
init(name: String) {
self.name = name
}
}
class Bar {
var fooObject: Foo = Foo(name: "FooName")
var keyPath = \Foo.name
func output() {
print(fooObject[keyPath: keyPath])
}
}
let bar = Bar()
bar.output()
Although, it works if you make a small change and try to output this:
print(fooObject[keyPath: \Foo.name])
Can someone explain? Is it still buggy or am I just doing something stupid here? Thanks.
You need to update to Xcode 9 beta 4, where it is fixed.