I have a model class that contains some static variables and properties. In Runtime I can get the properties;
let instance = entity.init()
let mirror = Mirror(reflecting:instance)
var propertyStrings = [String]()
for (propertyName, childMirror) in mirror.children {
}
But I want to get static variables of the class as a list too. So how can I get the list of static variable's names and values ? Here is my model class' structure :
class ActionModel: NSObject {
static let kLastModified = "LastModified"
static let kEntityName = "EntityName"
static let kIdentifier = "Id"
var lastModified: Int64
var entityName: String?
var identifier : PrimaryKeyString
Getting type properties via reflection is not supported yet. You can see this by inspecting the displayStyle
of the Mirror
you get if you pass the class object to the initializer:
let mirror = Mirror(reflecting: ActionModel.self)
print(mirror.displayStyle) // nil
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With