找不到“NSKeyValueObserving”的协议声明。但为什么?
@interface ThreadsViewController : UIViewController <NSKeyValueObserving>
{
}
错误:找不到“NSKeyValueObserving”的协议声明。
我正在使用基础框架。为什么我会出现这个错误?
@interface ThreadsViewController : UIViewController <NSKeyValueObserving>
{
}
Error:Cannot find protocol declaration for 'NSKeyValueObserving'.
I'm using Foundation framework. Why do I have this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
NSKeyValueObserving
是一个 非正式协议:您不能采用使用尖括号语法的非正式协议,即正式协议。使用非正式协议,您只需实现协议方法即可。您尝试在
@interface
块中遵守NSKeyValueObserving
协议:是编译器抱怨的原因。
来自 协议:
NSKeyValueObserving
is an informal protocol:You can not adopt an informal protocol using the angle brackets syntax, that is for formal protocols. With informal protocols, you simply implement the protocol methods. Your attempt to conform to the protocol
NSKeyValueObserving
in the@interface
block:is the reason why the compiler is complaining.
From Protocols:
您应该检查 NSKeyValueObserving 的文档。您可以在顶部找到框架所在的位置。只需确认您将该框架包含在您的项目中即可。
You should check the documentation for NSKeyValueObserving. In that you can find at top that in which framework resides. Just confirm that you are including that framework in your project.
您确定FoundationFramework 已添加到您的项目中?如果没有,请添加。
Are you sure FoundationFramework is added to your project? If not, add it.