Open mapo80 opened 5 years ago
Sorry, this isn't supported. If you know what the object type is, like in this example, you could always use key paths:
let obj = Info()
let xxx = obj[keyPath: \.user?.info]
Thanks for your answer, but object type it's not known.
Since objects are of codable type, I have performed the serialization of the object into Dictionary and from this I have retrieved the value through Keypath.
`
public func valueForKeyPath
return subDict.valueForKeyPath(keyPath: rejoined)
}
return value as? T
}
`
I think this is not the best approach for performance!
I have a complex classes of this type
`public class Info: Codable {
}
public struct UserModel: Codable { public var username: String? public var name: String?
}`
I want to access sub properties in this way "user.info", is it possibile?
var obj = Info() let xxx: String? = try? get("user.info", from: obj)