Debug Method in Xcode

I often find myself add a bunch of #ifdefs for code that I only want executed during the development but not in the shipped products. In order to make the code a bit easier to read I decided to make a small method that takes a C block (available in iOS 4.0 and Mac OS X 10.6) instead.

You would use it like this:

/*
 * Simple example of usage
 */

#include "debug.h"

int
main(int argc, **argv)
{
    debug(^ {
        // Your debug code here
    });

    return 0;
}

You can download debug.[ch] from GitHub and simply add them to your project. You also need to edit your project settings for the Debug configuration to set the DEBUG macro.

Project Settings Dialog

http://gist.github.com/534487