Getting started with Cocoa development

| No Comments

Some notes on random stuff I found out the hard way.

How to rename a NIB in XCode?

You don't. You do a SaveAs in Interface Builder, give it a new name, then delete the old one. Then you have to go into your class and change -(NSString*)windowNibName to return the name of the new file (minus the extension). Why this can't be done from within XCode is beyond me.

How to add a drawer to an existing window?

Create an NSDrawer object and then a custom view object. The custom view becomes the drawer content. Connect the NSDrawer's contentView to the custom view and parentWindow to the existing window.

How to add a toolbar to a main window?

Create a NSDrawer, set contentView to an NSCustomView and parentWindow to the actual main window. Then you can add a reveal button, by...

How to put controls into a split view?

Not shown in palette. Create objects first, then select them. Choose Layout|Make SubviewsOf|SplitView.

How to add an ellipsis "..." to a menu item?

Type Option-; (that is, semicolon).

Renaming a widget instance (such as a controller) in IB?

Double-click on the icon text itself and edit directly. (This is not at all obvious, since right-clicking (or control-clicking or whatever) doesn't reveal anything, and there doesn't seem to be a way to do it via the menu either.)

How to change the application icon (NSApplicationIcon)?

The default A icon is part of the bundle. To change it, create an image (ideally 128x128) and open up Icon Composer (from /Developer/Utilities). Paste in your image into the main icon size (and others as you wish) then save the icns file into your project. Go into XCode and add the file to your project (using Project|Add). Then select the application Target, then bring up the info window (Command-I). In the Properties tab, enter the filename (minus the .icns extension) of the icon you just saved. Rebuild and voila!

Leave a comment