上篇文章中我们提到,KVC模型在查找方法的时候,会查找诸如get***或者_***这种方法。

其实,KVC查找的形式还有很多,下面列出了所有KVC查找的方法形式,在程序中实现或者调用下面这些方法,都可以直接生成KVO通知(%s用于替换你定义的key):

 

  • validate%s:error:
  • %sForKeyPath:
  • _%sForKeyPath:
  • get%s
  • is%s
  • _get%s
  • countOf%s
  • objectIn%sAtIndex:
  • %sAtIndexes:
  • get%s:range:
  • enumeratorOf%s
  • memberOf%s:
  • _is%s
  • set%s:
  • _set%s:
  • getPrimitive%s
  • primitive%s
  • setPrimitive%s:
  • add%sObject:
  • remove%s:
  • remove%sObject:
  • add%s:
  • intersect%s:
  • insertObject:in%sAtIndex:
  • insert%s:atIndexes:
  • removeObjectFrom%sAtIndex:
  • remove%sAtIndexes:
  • replaceObjectIn%sAtIndex:withObject:
  • replace%sAtIndexes:with%s: