This is an old question, but the answer did not work for me.
I had to change my quick object to NSObject in order for everything to work, as well as have dynamic properties.
In my case, I use pod marshal to deserialize the data.
class MyClass: NSObject, Unmarshaling { // @objc dynamic make property available for NSObject @objc dynamic var myProperty: String? required init(object: MarshaledObject) throws { super.init() initUsingReflection(object: object) } func initUsingReflection(object: MarshaledObject) { let mirror = Mirror(reflecting: self) // we go through children for child in mirror.children { guard let key = child.label else { continue } // This line is here to get the value from json, in my case I already know the type I needed let myValue: String = try! object.value(for: key) // The trick is here, setValue only exist in NSObject and not in swift object. self.setValue(myValue, forKey: key) } } }
source share