Tricks
Some NSLog tricks I’m using on my escapade. These snippets are preprocessor macros that will help your debugging moments easier if not a lot.
ALog
This snippet will log everything every time you use it in a line. It will display the method name, the line number and the argument you gave.
#define ALog(fmt, …) NSLog((@”%s [Line %d] ” fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
DLog
This snippet will log everything every time you are in a DEBUG mode but has the same function of ALog.
#ifdef DEBUG
#define DLog(fmt, …) NSLog((@”%s [Line %d] ” fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DLog(…)
#endif
LFLog
#ifdef DEBUG
#define LFLog() NSLog((@”%s [Line %d]“), __PRETTY_FUNCTION__, __LINE__);
#else
#define LFLog(…)
#endif
This snippet will not take any arguments but will display the current file and method and the line number if you are in a DEBUG mode.
UALog
This snippet is much like DLog. It will take an argument and will display it, but in this case, it will display it using a UIAlertView instead of displaying it on the console.
#ifdef DEBUG
#define UALog(fmt, …) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle: [NSString stringWithFormat: @"%s\n[Line %d]“, __PRETTY_FUNCTION__, __LINE__] message: [NSString stringWithFormat: fmt, ##__VA_ARGS__] delegate: nil cancelButtonTitle: @”Ok” otherButtonTitles: nil]; [alert show]; }
#else
#define UALog(…)
#endif
The debugging process is tough, especially if …