Archive for the 'Cocoa' Category

NSWindow setResizable:

December 18, 2007

This article has been updated moved to a new location.

NSWorkspace Bug in - openFile: ?

December 7, 2007

EDITED TO ADD: I could reproduce this bug in a large project, but not isolate it in a smaller one. It is much likely for my code to have a bug then NSWorkspace. I’m still not 100% certain that this issue wasn’t my fault in some way I don’t understand. But no [...]

Design Process: Current Location “Headline”

November 10, 2007

This is a bit of the design process behind one line of one settings panel inside IMLocation.
The “Locations” panel controls everything having to do with to locations. The pane’s “headline”, outlined in red, shows what is assumed to be the current location.

It reads like “Your current location is home”. It does not say [...]

Interfacing With (Hacking) iChat in Leopard

November 1, 2007

Before you consider using any of the unsupported hacks I’m about to discuss, check to see if existing frameworks , or iChat’s AppleScript interface, will do what you need. Any software update can break unsupported code in unpredictable ways at any time. When Leopard came out, all the hacks I had been using [...]

Getting Mac OS X Version Information At Runtime

October 31, 2007

This article has been updated, and republished here.

Assert Outlet Connections

October 16, 2007

This simple NSCAssert has saved me a lot of bother. In any class that has an IBOutlet connected to something, Put
NSCAssert(outlet1 && outlet2 && … && outletn, @”An outlet got disconnected!”);
in the awakeFromNib method. Then if you ever accidentally disconnect an outlet, you’ll find out about it quickly.
I think this is a worthwhile [...]

Better AppleScript Through Expressions

October 13, 2007

When writing a short AppleScript to complete a specific task, do not write a procedure that checks if A exists, then operates on it if it does. Instead, write an expression that operates on A, and ignore any exceptions caused by A not existing. Surrounding the statement in a try-block will ignore any [...]

NSApplicationName Inconsistencies

October 11, 2007

This article has been updated, and moved here.

NSAlert Sheet Not Having Focus

October 11, 2007

EDITED TO ADD: Several months later, I ran into this same bug again!
I had an issue where if I used
beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:
to put up an NSAlert as a sheet inside a window, and I was not running on the main thread, the sheet would not have focus. I’m not sure exactly why, but this solution worked [...]

Objects that Won’t Hide

October 2, 2007

This article has been updated, and moved here.