Swift-setValuesForKeysWithDictionary

重写 setValuesForKeysWithDictionary 那么字典中可以有的字段在类中没有对应属性

class Person : NSObject {
    var age :Int = 0
//    重写 setValuesForKeysWithDictionary 那么字典中可以有的字段在类中没有对应属性
    override func setValuesForKeysWithDictionary(keyedValues: [String : AnyObject]) {
        
    }
}

let p = Person()
p.age = 20
print(p.age)

p.setValuesForKeysWithDictionary(["age":30,"name":"ww"])
print(p.age)
原文地址:https://www.cnblogs.com/WJJ-Dream/p/5822810.html