我有一个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/