swift2 - Reflection Swift 2.0 XCode 7 beta 5 -


apple has changed swift reflection in xcode 7 beta 5. global reflect() function gone, , you'll have this:

let mirror = mirror(reflecting: object) 

it gives more or less same information in nicer way (no more .1 og .2 propertyname , value). can't find way explore if mirrored item instance of class. older implementation check following:

reflectedproperty.1.objectidentifier != nil || reflectedproperty.1.count > 0 

but objectidentifier seems gone , count 2 regardless of type.

help anyone?

ok found workaround. iterating on mirror.children.enumerate() seemed make properties of type string. instead dug apple preliminary documentation, , read idea "upgrade" children e.g. anyrandomaccesscollection. made possible rely on count of objects children determine if it's object (after testing whether it's array)

currently have functioning swift class json serializer working here on gist if interested in code: https://gist.github.com/peheje/cc3618253d4f38ea4885


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -