Debugging Macros
May 26, 2009
In a previous post, Yet Another Debug Output Replacement, I wrote a macro that I prefer over NSLog as the output does not prepend the date/time and object information that NSLog does.
Since that time I’ve pulled together a few more macros that I use on a regular basis for printing debug information on rectangles, points and sizes. I’ve also included a means to turn debug information on/off so debug statements are not included in builds targeted as final releases.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Debug //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #define DEBUG_ON // Toggle to DEBUG_OFF to hide all debug code #ifdef DEBUG_ON #define debug(format, ...) CFShow([NSString stringWithFormat:format, ## __VA_ARGS__]); #else #define debug(format, ...) #endif #define debugRect(rect) debug(@"%s x:%.4f, y:%.4f, w:%.4f, h%.4f", #rect, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height) #define debugSize(size) debug(@"%s w:%.4f, h:%.4f", #size, size.width, size.height) #define debugPoint(point) debug(@"%s x:%.4f, y:%.4f", #pt, pt.x, pt.y) |



