Archive for January 7, 2007

Sunday, January 7, 2007


Jonathan “Wolf” Rentzsch has posted some interesting Cocoa error-wrapping macros. I’ve long used some macros to generate and raise NSExceptions that have the name, reason, and userInfo set based on the error code, a format, and the location in the source file. Rentzsch’s macros go beyond this to stuff the relevant information into a more modern NSError object, with the error domain cleverly deduced from the function’s return type using @encode and typeof. The NSXThrowError macro will also raise an NSException that has the NSError stuffed into its userInfo. Lastly, the actual Objective-C expression that generated the error code is saved as a string in the NSError.

Putting on my code critiquing hat, I don’t like that NSXThrowError introduces an exception name beginning with the reserved NS prefix or that the function-like macros implicitly assign to an error variable in the local scope. Also, they should probably be do-while protected.

Late Night Blog

Late Night Software’s Mark Alldritt has started a blog. In one of the first entries, he describes his 2007 plans for Affrus, FaceSpan, and (my favorite) Script Debugger.