cocoa - 如何消除编译器警告 "AppDelegate does not implement the NSTextView protocol"

标签 cocoa

我有一个NStextView在使用 IB 构建的 UI 中定义。我的 AppDelegate.m 文件中有以下内容,可以了解 textView 中的文本何时更改。

- (void)textDidChange:(NSNotification *)aNotification {
}

一切正常,但是编译器警告我的 Controller “WinKeyer2AppDelegate”没有实现 NSTextView委托(delegate)协议(protocol)。

我已经研究了这个问题,建议是将协议(protocol)声明添加到我的类接口(interface)定义中。我没有在 IB 中设置的 textView 的类接口(interface)定义。 textView Connections Inspector 中有一个“委托(delegate)”连接,但我该如何将其连接到什么,WinKeyer2AppDelegate 不起作用,而且我没有引用 NSText列出 textDidChange: 的对象其协议(protocol)引用中的项目。我尝试将 NSText 对象添加到我的 .xib 并将其连接到“delegate”,但这也没有帮助。

最佳答案

您需要在 WinKeyer2AppDelegate 的接口(interface)定义中包含 NSTextViewDelegate。

例如:@interface WinKeyer2AppDelegate : NSObject <NSApplictionDelegate, NSTextViewDelegate>

关于cocoa - 如何消除编译器警告 "AppDelegate does not implement the NSTextView protocol",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5515396/

相关文章:

ios - 有没有办法检测显示了多少模态视图 Controller ?

objective-c - 如何将 "takeStringValueFrom"与按钮 onclick 事件一起使用?

iphone - 如何让一段代码在单独的线程中运行?

objective-c - 当使用基于 View 的 NSOutlineView (源列表)使用绑定(bind)时,是否可以根据某些条件不显示数据源中的行?

Objective-C Mac OSX 应用程序 - 从另一个委托(delegate)获取变量?

ios - 在 Objective-C 中访问隐藏的私有(private)类

cocoa - 为什么 OSX 中今日小部件的名称始终是 "Widget"?

objective-c - 如何检查最前面的应用程序是否全屏?

objective-c - NSNotification 和 NSEvent 的区别

xcode - cocoa /苹果符号服务器