2011-08-13 46 views

回答

4

NSKeyValueObservinginformal protocol

An informal protocol is a category on NSObject, which implicitly makes almost all objects adopters of the protocol. (...) Implementation of the methods in an informal protocol is optional. Before invoking a method, the calling object checks to see whether the target object implements it.

使用尖括号语法,你不能采取非正式的协议,这是正式的协议。使用非正式协议,您只需实现协议方法。你试图顺应协议NSKeyValueObserving@interface块:

@interface ThreadsViewController : UIViewController <NSKeyValueObserving> 

是为什么编译器是抱怨的原因。

Protocols

Being informal, protocols declared in categories don’t receive much language support. There’s no type checking at compile time nor a check at runtime to see whether an object conforms to the protocol.

0

您应该检查NSKeyValueObserving的文档。在这里你可以在顶部找到框架所在的位置。只需确认您在项目中包含该框架即可。

相关问题