Status bar icon menu in swift

I’m writing this tutorial because I needed one for my app Blinkk ( ) and searched the web for a tutorial, naturally, but everything looked complicated and couldn’t make anything work. So the copy/paste solution was not possible and i decided to understand how it works programatically and ended up being very simple. I have no problem with outlets and xibs but the way they need to be wired for a simple menu makes me nervous, i have no patience to learn something that is more than an outlet to an UI element or an action.

So here it goes, this is all you need and can be placed in applicationDidFinishLaunching

Problems i faced:

  • item var should be strong referenced, otherwise you’ll see the icon disappear from the status bar
  • to enable items add a target to each NSMenuItem
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.