create the own custom class object

Not sure what your end goal is but you could use KeyPath here

struct MyCustomType {
    let id = 178
    let reg = "Expression<String?>(“reg”)"
    let date = Date()

    func runThis<T>(enter: KeyPath<MyCustomType, T>)
        print(self[keyPath: enter])


let x = MyCustomType()

x.runThis(enter: \.id)
x.runThis(enter: \.reg)
x.runThis(enter: \.date)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top