How to convert String to Struct (in Swift) -




i have struct like,

struct loginconstants {   struct selectors {     let testa = "test1234"   } } 

and class like,

class login: xctestcase {   override class func setup () {     // below constant have value "loginconstants"     let localconstants = "\(string(describing: self))constants"    } } 

... here have struct-name string format in localconstants.

my question how can access loginconstants properties localconstants string?

note: know can access loginconstants() directly. planning create parent class can access ***constants struct dynamically.

thanks help!

objective-c has ability this, swift not. if give class objective-c name via @objc attribute, can use objective-c runtime functions access name. however, not possible struct.

it's not best way go anyway. better solution rethink trying do, , access struct type directly rather name.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -

python - Read npy file directly from S3 StreamingBody -