import Foundation
@objcMembers
class People: NSObject {
var name: String?
var last_name: String?
var age: String?
var wallet: Wallet?
}
@objcMembers
class Wallet: NSObject
{
var cash = 1000
var credit = 2
}
var user = People()
user.name = "user name"
user.last_name = "user lastname"
user.age = "20"
user.wallet = Wallet()
let mirrored_object = Mirror(reflecting: user)
for (index, attr) in mirrored_object.children.enumerated()
{
if let key = attr.label
{
print("Attr \(index): \(key) = \(attr.value)")
user.setValue(nil, forKey: key)
}
}
user.last_name
user.age
user.wallet