I try to respect the status of the flag and make appropriate changes to the application when the status of the flag changes. In the window manager, which controls the window using a checkbox, I have the following observer setting:
- (void)awakeFromNib { [myCheckBox addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:NULL]; } - (void)dealloc { [myCheckBox removeObserver:self forKeyPath:@"state"]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { NSLog(@"KeyPath: %@", keyPath); NSLog(@"ofObject: %@", object); NSLog(@"change: %@", change); }
I also connected myCheckBox to the owner of the file (which is the window controller) to the corresponding checkbox in the window. However, when starting my application, observeValueForKeyPath:ofObject:change:context: method is never called.
What am I doing wrong?
source share