title: Swift - Is it possible to build the menu bar item outside AppDelegate class in a MacOS ManuBar App?
body: <p>I'm doing a lot at once and this is quite overwhelming sometimes. Learning how to build a mac os (with menu bar and a settings window) while learning swift and sometimes trying to adapt objective c tutorials into swift.</p>
  
  <p>I have followed <a href="http://www.johnmullins.co/blog/2014/08/08/menubar-app/" rel="nofollow">this tutorial</a> to help me get started with an app with a menubar. I have made it work, but now I want to improve it a little bit. </p>
  
  <p>All the menu setup in this example is within the AppDelegate class. Since my app has a little more stuff in it, a settings window where I also have to play with tables, I wanted to clean the menu related stuff to a responsible class I called MenuLoader. </p>
  
  <p>I moved all menu building related code from AppDelegate to MenuLoader, and I instantiate MenuLoader on AppDelegate's applicationDidFinishLaunching method. </p>
  
  <p>When I run the code though, the app menu bar item appears for what seems the time it is being loaded, with some breaking points I can see clearly that the objects exist and have expected properties, but then the it just disappears. I'm afraid I'm missing some connection the AppDelegate uses to keep a relation of the menu bar referenced. </p>
  
  <p>So my question is: is it possible to have a separate class handling only the status menu bar instead of having a big mess on the AppDelegate?  If you think this might be a matter of my implementation, I'll post some code here, though I'm not sure it will make much of a difference. </p>