Trying out Swift 4 in Xcode 9 Beta.
For some reason I'm getting a crash when using key value accessors on an NSObject.
Any ideas?
import Cocoa class Person: NSObject { var name = "" var age = 0 } let alpha = Person() alpha.name = "Robert" alpha.age = 53 alpha.value(forKey: "name") // error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). 
value(forKey:)with#keyPath(Person.name)instead of a string then the compiler will show a proper error message and Fix-it!print(alpha[keyPath: \Person.name]):) Then you don't have to inherit fromNSObjectand can even makePersonastruct.let name = \Person.name, but they're not strings (they're strongly typed instead). Strings are such weak types to represent key-paths, and should really be avoided unless absolutely necessary. What's your use case for using a string key path?