inessential by Brent Simmons

December 2006

Five Things People Don't Know About Me

Five Things People Don’t Know About Me

I was tagged by Nick.

1. I usually wear all black at home. It matches the way I feel on the inside. ;)

2. The one sport at which I’m quite good, at which I can usually beat everyone in the room (unless the room contains my dad and/or brother-in-law), is ping pong.

3. I didn’t finish college, and didn’t take any computer science classes in college. (Had I gotten as far as declaring a major, it would have been English. I probably would have concentrated on 20th century American literature—particularly the first half of the century, the modernists.)

4. I play guitar and piano—with little skill but plenty of enthusiasm.

5. There’s a surprising amount of Public Enemy in my iTunes library.

I’ll tag five local Seattle Xcoders folks: Gus Mueller, Joe Heck, David Dunham, Andrew Carter, and Greg Martin.

Launching an app synchronously

When NetNewsWire sends a news item to a weblog editor app, it sends an Apple event to that app. But first it needs to make sure the app is running, so that it can receive the Apple event.

When I first added this feature, I had some weird thing where NetNewsWire launched the app then waited for a notification that the app had launched—and then it would send the Apple event. It took a surprising amount of code.

I decided that it was okay to launch the weblog editor app synchronously. Since -[NSWorkspace launchApplication:] is async, I needed something else. Turns out it was totally easy. Given f as the path to the app:

LSLaunchURLSpec launchSpec;
launchSpec.appURL = (CFURLRef)[NSURL fileURLWithPath:f];
launchSpec.itemURLs = nil;
launchSpec.passThruParams = nil;
launchSpec.launchFlags = kLSLaunchAndDisplayErrors;
launchSpec.asyncRefCon = nil;
return LSOpenFromURLSpec(&launchSpec, nil);

Anyway—so if you’re writing a newsreader or browser and need to launch a weblog editor before sending it the post-to-weblog Apple event, you can use the above code to launch the weblog editor. (Or use it for launching any app, of course.)