【发布时间】:2012-03-05 12:29:28
【问题描述】:
我有一个类(“TextEditorViewController”),里面有一个 NSTextView(“textView”)对象。我已将它与 .xib 文件中的 NSTextView 连接起来。这是我的 .h 文件:
#import <Foundation/Foundation.h>
@interface TextEditorViewController : NSObject {
IBOutlet NSTextView *textView; // connected in MainMenu.xib
IBOutlet NSTextField *displayCharacters; // connected in MainMenu.xib
}
@end
这是我的 .m 文件:
#import "TextEditorViewController.h"
@implementation TextEditorViewController
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSLog(@"applicationDidFinishLaunching called"); // printed to the debugger
[textView setDelegate:(id)self];
}
- (void)controlTextDidChange:(NSNotification *)obj {
NSLog(@"controlTextDidChange called"); // don't printed to the debugger ???
[displayCharacters setIntValue:[[textView string] length]];
}
@end
但是当我更改 NSTextView 中的文本时,它不会调用 controlTextDidChange:! 为什么?
感谢您的回答! =)
【问题讨论】:
标签: objective-c class delegates text-editor nstextview