我尽量使其简短,如果我提供的信息不够,请不要误会我的意思:
我在基于文档的 cocoa 应用程序中得到了一个 NSTextView,这是 a tutorial by Apple for programming a text editor within 15 minutes 的结果。在我的“PureBasicDocument.m”实现中,我得到了 textDidChange 方法,每次我在 NSTextView 中更改某些内容时都会调用该方法。我还获得了 textStorageDidProcessEditing 通知的方法,但它从未被调用。我如何调用它?我确信我只是忘记分配销售点或类似的东西。但一遍又一遍地盯着 textView 和它们的导出窗口并没有让我走得更远。我一无所知。总比没有好,现在至少有我的文档类的头文件(“PureBasicDocument.h”):
#import <Cocoa/Cocoa.h>
@interface PureBasicDocument : NSDocument {
IBOutlet NSTextView *textView;
NSAttributedString *mString;
}
- (NSAttributedString *) string;
- (void) setString: (NSAttributedString *) value;
- (void) textDidChange: (NSNotification *) notification;
- (void) textStorageDidProcessEditing: (NSNotification *) notification;
@end
如果我没有正确使用“委托(delegate)”(以及其他)表达式,我再次表示歉意,总的来说,我对 Objective-C 和 Mac 编程仍然完全陌生。
最佳答案
右键单击MainMenu.xib中的pureBasicDocument对象。您可以看到outlet(textView)。 从那里您可以连接到相应的 TableView 。 确保您是否已包含委托(delegate)
关于objective-c - 如何委托(delegate) textStorageDidProcessEditing 通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6849963/