How can you get a string value from Swift 4 smart keypaths syntax (e.g., \\Foo.bar)? At this point I\'m curious about any way at all, does not matter if it
\\Foo.bar
Expanding on @Andy Heard's answer we could extend KeyPath to have a computed property, like this:
KeyPath
extension KeyPath where Root: NSObject { var stringValue: String { NSExpression(forKeyPath: self).keyPath } } // Usage let stringValue = (\Foo.bar).stringValue print(stringValue) // prints "bar"