Category Archives: TheCodeBook – Snippets

A drop-in replacement for NSLog()

I recently saw this post on turning off NSLog for non-debug builds, and found it disappointing and inspirational at the same time. Scattering hundreds of #ifdefs around code is a recipe for disaster. Eventually some non debugging code will end up inside the #ifdef and the debug and release builds will function differently, making debugging [...]

Also posted in TheCodeBook - Snippets | Comments Off

Dual Monitor Screen Savers

How to create an OSX screen saver that works cooperatively across multiple monitors.

Also posted in TheCodeBook - Snippets | Comments Off

Finding new files

This isn’t so much code as a useful command line trick for finding where a program is storing information.

Also posted in TheCodeBook - Snippets | Comments Off

NSDrawNinePartImage

There is a cool new function in Leopard for drawing scaled rectangles of arbitrary width and height that keeps the corner and sides properly scaled while growing the center. Unfortunately there is no documentation, and when I last looked a whopping 3 google hits for the function name. This should make it number four.

Also posted in TheCodeBook - Snippets | Comments Off

QLog()

This Snippet is an alternative to NSLog. NSLog is great for occasional logging of debug and status message. It can however be a bit verbose because it includes the timestamp, process name, and process id on every line. If you are writing a command line tool this is overkill.QLog removes all this extra information and [...]

Also posted in TheCodeBook - Snippets | Comments Off
  • iChat Status