ios之KVC、KVO

  • KVC是KeyValueCoding的简称,它是一种可以直接通过字符串的名字(key)来访问类属性的机制。而不是通过调用Setter、Getter方法访问。
  • 获取值
  • - (id)valueForKey:(NSString *)key;
    - (id)valueForKeyPath:(NSString *)keyPath;
    - (id)valueForUndefinedKey:(NSString *)key;
    

     

  • 设置值
  • - (void)setValue:(id)value forKey:(NSString *)key;
    - (void)setValue:(id)value forKeyPath:(NSString *)keyPath;
    - (void)setValue:(id)value forUndefinedKey:(NSString *)key;
    

     

posted on 2015-03-06 17:40  sfce  阅读(164)  评论(0编辑  收藏  举报

导航