2011-08-13 16 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.

あなたが正式なプロトコルのためである角括弧構文を使用して非公式のプロトコルを採用することはできません。非公式のプロトコルでは、単にプロトコルメソッドを実装するだけです。 @interfaceブロック内のプロトコルNSKeyValueObservingに準拠するためにあなたの試み:

@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のドキュメントを参照してください。その中で、どのフレームワークが存在するのかを一番上に見つけることができます。プロジェクトにそのフレームワークを組み込んでいることを確認してください。

0

FoundationFrameworkはプロジェクトに追加されていますか?そうでない場合は、追加します。