Search code examples
objective-cmacososx-mountain-lion

NSStatusItem app development


I'm beginning some OS X development, I am reasonably accomplished with objective C and UIKIT.

There doesn't seem to be as much online about moving from iOS development to OS X as I thought there would be!

Anyway, I found a decent tutorial over a Ray Wenderlich, that basically explained the differences, (multiple NSWindows, then add to them NSViewControllers etc)

What I would like to do is make a little app that shows info in the status bar (beside the Wifi icon etc)

Basically all it does is have an NSStatusitem that has it's title set with info I want shown (e.g. current song title)

I've got one going and it's working ok so to my question:

I've got Application is agent (UIElement) (so I cannot see a dock icon or menubar)

The code for my little app all resides in the app delegate, now from iOS dev i'm sure this is not the right place for this code, but since the app is a just a status bar item, that has it's title updated I don't think I need a UIViewController etc....

  1. Where should my apps logic go?

  2. Anything online to transition from iOS to OS X?


Solution

  • As you dont have much work with NSWindows and NSViews, you surely dont need NSWindowController or NSViewController.

    And I think for this kind of app even your AppDelegate class is enough and best place to put all your logic.

    If you have some models then you can break your code upto that, and use it in the AppDelegate itself.


    Transition from iOS to OSX.

    If you are good in Objective-C then you dont have to worry about few more Cocoa-Controls especially GUI levels, you have full support of Documentation.

    Switching between iOS to OSX, vice-versa is not to difficult, but yes if you end up with system level then you need to interact with OSX too.