5

I have a class ("TextEditorViewController") within there is a NSTextView ("textView") Object. I've connected it with the NSTextView in my .xib file. Here 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 don't call controlTextDidChange:! Why?

Thanks for answers! =)

User
  • 31,811
  • 40
  • 131
  • 232
qwertz
  • 14,614
  • 10
  • 34
  • 46

2 Answers2

1

It worked after rebuilding the files in a new project. Seems like a file management configuration issue.

Dungeon Hunter
  • 19,827
  • 13
  • 59
  • 82
qwertz
  • 14,614
  • 10
  • 34
  • 46
0

Move the delegate part to viewDidLoad.
Why do you don't put this to a viewcontroller?

FrediWeber
  • 1,099
  • 1
  • 10
  • 21