Skip to content

Instantly share code, notes, and snippets.

@sendoa
Created July 9, 2013 20:33
Show Gist options
  • Save sendoa/5961029 to your computer and use it in GitHub Desktop.
Save sendoa/5961029 to your computer and use it in GitHub Desktop.
NSLog and NSAssert substitution macros based on the ones from Marcus Zarra http://www.cimgf.com/2010/05/02/my-current-prefix-pch-file/ When the app runs on "Release" mode, assertions are linked to TestFlight checkpoints. I always name assertion type checkpoints with "ASSERTION" prefix. Example: Alog(@"ASSERTION_NON_PARSEABLE_ITEM_DATA_RECEIVED");
#ifdef DEBUG
#define DLog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
#define ALog(...) [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding] file:[NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding] lineNumber:__LINE__ description:__VA_ARGS__]
#else
#define DLog(...) do { } while (0)
#define ALog(...) [TestFlight passCheckpoint:[NSString stringWithFormat:__VA_ARGS__]]
#ifndef NS_BLOCK_ASSERTIONS
#define NS_BLOCK_ASSERTIONS
#endif
#endif
#define ZAssert(condition, ...) do { if (!(condition)) { ALog(__VA_ARGS__); }} while(0)
@oliverbarreto
Copy link

gracias por compartir !!!

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