A very simple debug method that takes a block and only executes it if the DEBUG flag is set.
In Xcode you set this by adding
DEBUG=1to Preprocessor Macros in your Project Build Settings for your Debug configuration.
| /* | |
| * debug.c | |
| * Easy Shop | |
| * | |
| * Created by Mikael Hallendal on 2010-08-18. | |
| * | |
| */ | |
| #include "debug.h" | |
| void debug(DebugBlock debugBlock) | |
| { | |
| #ifdef DEBUG | |
| debugBlock (); | |
| #endif | |
| } |
| /* | |
| * debug.h | |
| * Easy Shop | |
| * | |
| * Created by Mikael Hallendal on 2010-08-18. | |
| * | |
| */ | |
| typedef void (^DebugBlock)(void); | |
| // Method that takes a block and only executes it if DEBUG is set | |
| void debug(DebugBlock debugBlock); |
| /* | |
| * Simple example of usage | |
| */ | |
| #include "debug.h" | |
| int | |
| main(int argc, **argv) | |
| { | |
| debug(^ { | |
| // Your debug code here | |
| }); | |
| return 0; | |
| } |