I'm trying to hook a NSTextField
to a NSTextFieldDelegate
to implement the controlTextDidChange
.
// TFDelegate.h
#import <Cocoa/Cocoa.h>
@interface TFDelegate : NSObject <NSTextFieldDelegate>
@end
// TFDelegate.m
#import "TFDelegate.h"
@implementation TFDelegate
- (void)controlTextDidChange:(NSNotification *)notification {
NSLog(@"controlTextDidChange");
}
@end
// ViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
TFDelegate *del = [[TFDelegate alloc] init];
[self.TimeInput setDelegate:del];
}
As soon as I start typing something in the TimeInput
-NSTextField, my app crashed with a EXC_BAD_ACCESS
. I don't see why my app would try to access memory that doesn't exist? Did I do something wrong with the instantation/allocation of my TFDelegate
?