Sunday, September 13, 2009

Toolbars in Interface Builder



Making a toolbar for a Cocoa application has become as simple as 1-2-3, with the use of Interface Builder. You just:

• drag a toolbar onto your window
• double click it to show "Allowed Toolbar Items"
• drag an "Image Toolbar Item" to the "Allowed Toolbar Items"
• set its Image Name to one present in your project resources
• drag the item from the "Allowed Toolbar Items" to the toolbar (not obvious at first)
• connect it to an IBAction in your controller


I have to confess I fooled around for a while because I didn't find the right Apple docs for this. Once you know how, it is truly painless.