I'm using Swift property wrappers to define something like:
@MyWrapper var foo: Int
And in the implementation of the property wrapper, I'd like to access the name of the variable, foo, as a string. Something like this:
@propertyWrapper
public struct MyWrapper<Type> {
init() {
// Get access to "foo" -- name of var as String
}
}
Suggestions?
xy
question? In the @propertyWrapper implementation I need a name that I use to store data in, say, user defaults-- specific to this property. I can (and am doing this now) pass the name as an init parameter. But, it seems cleaner to at least give a parameter default that's the name of the variable. – Kentiga#var
, analogous to#function
(see #24403033). I need to put this on the Swift dev forum. – Kentiga