This error message is a straight forward error, where the parser is expecting a keyPath
, given the usage of the backslash (assuming that this is the issue causing the problem, considering that the previous answer from @Edmund Holderbaum was accepted).
Excerpt From: Apple Inc. “The Swift Programming Language (Swift 5.0).”
Key-Path Expression. A key-path expression refers to a property or
subscript of a type. You use key-path expressions in dynamic
programming tasks, such as key-value observing. They have the
following form:
\type name.path
There seems to be few places in the Swift grammar where a backslash is used, other than in string interpolation (interpolated-text-item) or in a escaping sequence (escape-sequence).
from Summary of the Grammar - Lexical Structure
“key-path-expression → \ type opt . key-path-components”
Take a look at this excellent post to learn more about keyPaths
in Swift: https://www.swiftbysundell.com/posts/the-power-of-key-paths-in-swift