Search code examples
objective-cmacoscocoansapplication

Aren't I allowed to override -sendEvent: in my NSApplication subclass?


In my mac os x app, I subclass NSApplication and override it's -sendEvent: method. Apple complains :

The app includes 'OBJC_IVAR_$_NSApplication._delegate' from the framework '/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit'.

What can I do about that? What am I doing wrong?


Solution

  • You are accessing the application delegate by directly referring to the _delegate ivar, like this:

    NSLog(@"my delegate = %p", _delegate);
    

    You need to use the delegate accessor method, like this:

    NSLog(@"my delegate = %p", self.delegate);