rentzsch.com: tales from the red shed

Cocoa Java Tips

Mac OS X
This week I wrote some personal time-tracking software in Cocoa, and it was my first foray into Cocoa Java. Some lessons learned:
  • NSTextFormatter is broken out-of-the-box, and has been since the beginning of time (or at least 2000, circa WebObjects 4.5, which also had a ObjC-Java bridge). Fortunately, Benjamin Riefenstahl posted a runtime patch that fixes the problem. Do I even bother filing a bug about this? I know, I know...
  • The bridge is not amused when you get your types wrong. Consider this target action code:

    public void updateInitialEstimate(NSFormCell sender) {
      sender.doubleValue();
    }

    This code will unceremoniously terminate your entire process, sans error or exception. You need to do this, instead:

    public void updateInitialEstimate(NSControl sender) {
      sender.doubleValue();
    }
  • (Not Cocoa-Java Specific:) In Interface Builder, copying and pasting views (even within the same window) kills all its connections, leading to runtime NullPointerException land when your outlets never get hooked up for you.
  • (Also Not Cocoa-Java Specific:) PBX crashes. A lot. Save often.

Friday, June 13, 2003
12:00 AM