Set titles of menu items


I have a NSMenu. What I’d like to do is add menu items to a submenu of it so that each menu item is the name of an iTunes playlist and so that when I click them, it launches iTunes and plays the playlist.

I’d like to add them as/after the application has launched rather than… say… storing the details in a file, because the playlist list might change a lot.

Also, I’d like to know how to do something similar, but add menu items and set their titles to all of the files/folders in /MyUserName/Documents .

Any help would be appreciated!

You create a new menu item using NSMenuItem and alloc() plus initWithTitle:action:keyEquivalent:, where you supply the menu title, the name of the action handler it calls, and a key equivalent. You then add it to your menu by caling addItem:.