ios - Comparing the datatype of an inner class attributes to its corresponding datatype -
i want know attributes datatype of class has inner class objects while iterating.
find code mentioned below.
class myclass1: nsobject { var name:string? var id:int32? } class myclass2:nsobject { var sessionid:string? var classobj:[myclass1]? var item:int? } let mirroredobject = mirror(reflecting: myclass2()) var dictionary = [string:any]() for(index,attr) in mirroredobject.children.enumerated() { if let property_name = attr.label { let submirroredobj = mirror(reflecting: property_name) dictionary["\(property_name)"] = type(of: (attr.value)) any? } } (index,item) in dictionary.enumerated() { print(item.value) }
in above code display list of attributes of classobject. here don't know how compare listed attributes of class.
use type of property:
attr.value.dynamictype
Comments
Post a Comment