
Untitled
By: a guest on
May 8th, 2012 | syntax:
None | size: 1.57 KB | hits: 16 | expires: Never
Why is this code not KVO-Compliant?
@interface ILViewController : NSViewController
- (ILWindowController *)windowController;
@end
@implementation ILViewController
- (NSWindowController *)windowController {
return self.view.window.windowController;
}
- (void)setView:(NSView *)view {
[self willChangeValueForKey:@"windowController"];
[super setView:view];
[self didChangeValueForKey:@"windowController"];
}
@end
Cannot update for observer <NSAutounbinderObservance 0x1005cf990> for the key path
"windowController.mainStatus" from <ILViewController 0x1001976b0>, most likely because
the value for the key "windowController" has changed without an appropriate KVO
notification being sent. Check the KVO-compliance of the ILViewController class.
@interface ILViewController : NSViewController {
ILWindowController *_windowController;
}
- (ILWindowController *)windowController;
@end
@implementation ILViewController
- (NSWindowController *)windowController {
return _windowController;
}
- (void)setView:(NSView *)view {
[super setView:view];
_windowController = view.window.windowController;
}
@end
KVO autonotifying only supports -set<Key>: methods that return void. Autonotifying
will not be done for invocations of -[NSView _setWindow:].
Cannot remove an observer <NSKeyValueObservance 0x102e17880> for the key path
"window.windowController.mainStatus" from <NSView 0x102e13ec0>, most likely because
the value for the key "window" has changed without an appropriate KVO notification
being sent. Check the KVO-compliance of the NSView class.