Alerts Without Apps (or nibs)

Quickie for today that some people might find handy. (I need to start posting much more. And reorganize a bit.)

Just yesterday I found myself wondering what to do when Dockyard would crash. The new Dockyard uses the wonderfully transparent distributed objects of Cocoa, which become staggeringly destructive when the remote process crashes. If you only used the data in a few places, or transferred everything by-copy, then you can probably recover. But in the bindings-intensive AppKit world of Dockyard Manager, you’re going to crash before you can say [[self window] close:nil] (I tried.) The bindings all try to update and come back complaining about a broken connection. The only thing that worked was to bail out, but if I tried to show an NSAlert to tell the user we had to bail out, the app got stuck in the modal loop. I have no idea why, but I can only assume it’s because the hordes of orphaned object proxies have destroyed all of the run loops by this point.

(I’d like to know why I can’t just use NSAlert, but I have no idea where to go from the bit of poking I did. Pausing during the alert reveals an apparently normal run loop, but the alert simply won’t close.)

So, I have decided instead to bail out as planned, but to show an alert after the application quits. (Huh‽) Rather than use AppleScript’s “display alert”, which doesn’t look as nice, requires twice as much space as my final solution, and (the clincher) doesn’t work on Panther outside of AppleScript Studio, I wrote a small application intended to be called with a property list file describing the parameters of the alert.

The application wouldn’t be so remarkable, except that it works and it’s nibless. Even if you don’t care about the app itself (to be fair it’s really odd to want to display an alert without having an application context already, and a better sudden death app might be needed in the end), you might still be a bit interested in how to write a nibless application.

Summary: nibless faceless application that displays alerts based on a property list file description. If you’re interested at all, you can e-mail me and I’ll send you the source for what I’ve named Alert Notifier. (It used to be online, but got lost when I changed hosts.)