0

Here is a code how I add a status bar with text:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NSStatusBar *bar = [NSStatusBar systemStatusBar];
    _statusBarItem = [bar statusItemWithLength:NSVariableStatusItemLength];
    [_statusBarItem setTitle:@"Status"];
    [_statusBarItem setHighlightMode:YES];
    [_statusBarItem setMenu:_menu];
}

It appears and disappears immediately after I launch my app. How to fix that?

I use Xcode 6.0 and Yosemite 10.10

I used an example of creating status bar from: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/StatusBar/Tasks/creatingitems.html

Serge
  • 2,031
  • 3
  • 33
  • 56
  • 1
    possible duplicate of [NSStatusItem appears briefly on launch, but promptly disappears](http://stackoverflow.com/questions/8873418/nsstatusitem-appears-briefly-on-launch-but-promptly-disappears) – markhunte Oct 27 '14 at 08:51
  • Solved by changing property from weak to strong for _statusBarItem – Serge Nov 01 '14 at 13:02

1 Answers1

0

Solved the problem by changing property from weak to strong for _statusBarItem

Serge
  • 2,031
  • 3
  • 33
  • 56