Potion Factory Blog

Category Cocoa

F#$% Nil Outlets

This is for you cocoa developers out there.

A common error I keep making is forgetting to set an outlet in Interface Builder. Usually I catch the problem pretty quickly but once in a blue moon it can leave me scratching my head for too long a period of time to confess here.

I love problems that can be engineered away and after making this mistake yet again, I decided to solve it once and for all. I'm sharing the solution because it has worked out splendidly.

The following code parses your header file for outlets and makes sure that they are set at runtime.

How to Keep Backwards Compatibility and be Less Grumpy About It

I dread backwards compatibility. I dread it because it means that for every product that I need to keep backwards compatible, the testing burden is at least twice as big. The math is simple: testing on two major OS versions and two processor types can be as much as 4 times of stuff I'd rather not be doing.

The last time I had to maintain a product with backwards compatibility, this is what I used to do:

  1. Build then copy application to test machine.
  2. Get it to fail. This is the one part where I don't have to work very hard.
  3. Try to fix while scratching head then proceed to littering print statements all over the code.
  4. Go back to step 1.

You can make this process a little less sucky by configuring Xcode to copy after each build, or by mounting a share so that there's no copying at all. But in the end, debugging with print statements alone is limiting and time consuming. There has to be a better way, right?

Quick NSDate Warning

This is a quick warning for Cocoa programmers.