I am trying to create an application that, when the main window is not displayed, shows an icon in the menu bar. However, I am not sure about this code and everything is in order. I get no errors and no warnings, but after several applications switch between my application and another, for example. Twitter or Safari I get
Program signal: "EXC_BAD_ACCESS".
Here is my code:
- (void)applicationDidResignActive:(NSNotification*)aNotification
{
statusItem = [[[NSStatusBar systemStatusBar]
statusItemWithLength:NSVariableStatusItemLength]
retain];
[statusItem setHighlightMode:YES];
[statusItem setEnabled:YES];
[statusItem setToolTip:@"Nucleus"];
[statusItem setMenu:theMenu];
[statusItem setTitle:[NSString stringWithString:@"N"]];
}
- (void)applicationDidBecomeActive:(NSNotification*)aNotification
{
[statusItem release];
}
source
share