Select Page

Creating a Mac OS X status bar application is really straightforward. However, below you will find a condensed step-by-step tutorial to avoid unnecessary mistakes.

  1. Create a new Xcode Cocoa Application project
  2. Go to Info.plist  file and add the key Application is agent (UIElement) and set it to YES
    <key>LSUIElement<key>
    <true/>
  3. Add two new properties to your app delegate header file. These two properties will contain the main status item displayed in the status bar and its associated NSMenu  menu:
    @property (strong, nonatomic) IBOutlet NSMenu *statusMenu;
    @property (strong, nonatomic) NSStatusItem *statusItem;
  4. Open MainMenu.xib and add new NSMenu  Control. Connect the NSMenu  control with your statusMenu  outlet in your app delegate. Finally delete the window control and save the nib file.
  5. Go to applicationDidFinishLaunching: or awakeFromNib method of your app delegate.
  6. Add the following code to create your status item, set the title (which will be displayed in the status bar), add the status menu to your status item and activate the highlighting mode.
    self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
    [self.statusItem setMenu:self.statusMenu];
    [self.statusItem setTitle:@"My App"];
    [self.statusItem setHighlightMode:YES];
  7. Run the application and you should see My App on your status bar. By activating the status item you will see the three default menu items too.