Friday, February 19, 2010

NSUnknownKeyException

Ran into this when I was trying to clean out unused properties from my class. The problem: I was still referencing a deleted property in the xib. Whoops. Props to Bill Dudney.

Forward Declarations in Objective C

Wow. Somehow I missed this.

Forward declarations in Objective C are implemented via the @class directive. In general, #import shouldn't be used in header files to bring in other classes in the application; import these only in the implementation file. In header files, use @class instead, which merely tells the compiler that the listed names are names of classes declared elsewhere. Not following this advice can lead to an assortment of maddening error messages, most of which have to do with cyclical class dependencies (the error message "expected specifier-qualifier-list before", for example.

Wednesday, February 17, 2010

Suppressing the iPhone Status Bar

If you want to run your app using all 320 x 480 pixels, you'll need to do two things:
  1. Set your views to 320 x 480. Your main view (the one in "MainWindow.xib"), as well as any other views you create that you want to take up the full screen area must be set to a size of W: 320 and H: 480. As noted previously, these values can only be edited if the Simulated Interface Elements are all set to "None".
  2. Suppress the status bar. The status bar is the area at the top of the display that shows battery life, signal strength, etc. In order to turn it off, you'll need to change a setting in your app's Info.plist file. In Xcode, it's typically in the Resources folder with the naming convention appname-Info.plist. Double-click the file, and look for the row labeled "Status bar is initially hidden". If you don't see it, click one of the existing values, click the "+" icon on the right, and select "Status bar is initially hidden" from the dropdown list. Make sure this value is true (has a checkmark next to it).
Enjoy running your app in fullscreen glory!