0

So let's say I have a struct like so:

struct Foo {
    let value: Int
}

And thus I have a key path defined for \Foo.value:

let keyPath = \Foo.value

Is there any way to query the text name of a KeyPath at runtime?

I.e. I would like to be able to do something like this:

print(name(of:keyPath)) // prints "value" or "Foo.value"
Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
sak
  • 2,612
  • 24
  • 55

0 Answers0