重写 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)

 

相关文章:

  • 2021-04-29
  • 2022-02-22
  • 2021-09-18
  • 2022-12-23
  • 2021-08-23
  • 2021-07-05
  • 2021-09-14
猜你喜欢
  • 2021-05-25
  • 2022-12-23
  • 2021-07-01
  • 2021-12-02
  • 2021-09-12
  • 2022-12-23
相关资源
相似解决方案