views:

47

answers:

1

Hi folks,

I am developing a small app that display the active mounts in a menu in the NSStatusBar. So far it looks like this: alt text

I want to add an eject button to the right of each menu item (like the left bar in the Finder). I know that I have to create a custom view and set it with the setView: method. The problem is that I am very new to Cocoa and right now I don't know how to dive into the custom view topic. Actually, I programmed a lot but never worked with interfaces so far :). Does anyone of you have a good tutorial for adding a custom view to a NSMenuItem?

I think this app will be very handy because you can hide the mounted icons from your desktop. The problem is that you always have to go back to the finder to unmount a volume...

Thanks for any help or tips you have!

A: 

It doesn't have to be a custom view. It can just be a standard NSView that acts as a container for standard controls.

The tricky part for a newbie is making the view reusable. You'll want your own NSViewController subclass with a corresponding view nib/xib (set up with your name label and eject button). For each menu item, you'll instantiate a new NSViewController with the XIB ( -initWithNibName:bundle: ) and set its represented object to your mount point. Your view controller subclass will have all it needs to respond to the eject button click, set the label to its represented object's path, etc.

Joshua Nozzi