ios - Swift / Objective C: How to get value from object by string name -
ios - Swift / Objective C: How to get value from object by string name -
class { var x = 1 } var = a()
how variable "x" object "a" using string name ( a["x"] )?
this work if class inherits nsobject, can utilize valueforkey: @ properties.
import foundation class a: nsobject { var x = 1 } allow = a() allow aval = a.valueforkey("x") println("\(aval)") note aval anyobject? here since there's no type information. you'll need cast or test yourself.
ios objective-c xcode swift
Comments
Post a Comment