NSTextView does not call controlTextDidChange:

I have a class ("TextEditorViewController") inside an NSTextView object ("textView"). I linked it to an NSTextView in my .xib file. Here is my .h file:

#import <Foundation/Foundation.h> @interface TextEditorViewController : NSObject { IBOutlet NSTextView *textView; // connected in MainMenu.xib IBOutlet NSTextField *displayCharacters; // connected in MainMenu.xib } @end 

And here is my .m file:

 #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 

But when I change the text in my NSTextView, it does not call controlTextDidChange :! Why?

Thanks for answers! =)

+4
source share
2 answers

It worked after restoring files in a new project. This seems like a file management configuration issue.

+1
source

Move the delegate part to viewDidLoad.
Why don't you put this in the view manager?

0
source

Source: https://habr.com/ru/post/1399771/


All Articles