1,方法中存在SEL类型参数时,检测SEL方法与对象是否匹配(或者说是否有实现)
- (void)observe:(nullable id)object 
        keyPath:(NSString *)keyPath 
        options:(NSKeyValueObservingOptions)options 
         action:(SEL)action {
  ...code...
  NSAssert([_observer respondsToSelector:action], @"%@ does not respond to %@", _observer, NSStringFromSelector(action));
  ...code...
}

来源:KVOController

results matching ""

    No results matching ""