mercredi 10 août 2016

Reflection in Swift, children value is 0 if type is NSNumber

I am trying to use reflection to print the values of the properties in my Data object.
If the property type is NSNumber, the value printed is 0 (not the correct value), while if the property is NSDate the date gets printed correctly.
Here is the code i'm using

let mirrored_object = Mirror(reflecting: data)
  for children in mirrored_object.children {
     print("\(children.value)")
  }
} 

Why does it print 0 as the value of my properties?





Aucun commentaire:

Enregistrer un commentaire