2011-08-13 48 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的文檔。在這裏你可以在頂部找到框架所在的位置。只需確認您在項目中包含該框架即可。

相關問題