Skip to content

Instantly share code, notes, and snippets.

@nuclearghost
Last active August 29, 2015 14:05
Show Gist options
  • Save nuclearghost/0cc383ce7bc1abdadf4c to your computer and use it in GitHub Desktop.
Save nuclearghost/0cc383ce7bc1abdadf4c to your computer and use it in GitHub Desktop.
Objective C Custom Log Macros
#ifdef DEBUG
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
# define DLog(...)
#endif
// ALog always displays output regardless of the DEBUG setting
#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
@nuclearghost
Copy link
Author

With current Xcode, you can make use of the z and t modifiers to handle NSInteger and NSUInteger without warnings, on all architectures.

You want to use %zd for signed, %tu for unsigned, and %tx for hex.

From SO: http://stackoverflow.com/questions/4405006/nslog-printf-specifier-for-nsinteger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment