json - Can I set values for a Swift object properties using mirroring? -


right can inspect variables of object using mirror type. can set values variables using mirroring? or maybe there's pure-swift way?

for example, i'd create object (a swift struct) json. possible without subclassing nsobject , using objective-c functions that?

this best can @ moment. still missing converting mirrorobject generic type. fyi using swiftyjson

func converttoobject<t>(json: json, genericobject: t) -> t {     let mirroredobject = mirror(reflecting: genericobject)      (_, var attr) in mirroredobject.children.enumerate() {         if let propertyname = attr.label string! {             attr.value = json[propertyname]             print(propertyname)             print(attr.value)         }     }     // figure out how convert object type... } 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

node.js - Express and Redis - If session exists for this user, don't allow access -

excel - I can't get the attachement of the email PHP -