Create a gist now

Instantly share code, notes, and snippets.

@olxios /Log.h
Last active Jun 26, 2016

How to use NSLog and print only for debugging? http://swiftiostutorials.com/use-nslog-debugging/
#import <Foundation/Foundation.h>
@interface Log : NSObject
extern void SSLog(BOOL releaseLog, NSString *format, ...) NS_FORMAT_FUNCTION(2,3);
@end
#import "Log.h"
@implementation Log
void SSLog(BOOL releaseLog, NSString *format, ...)
{
#ifndef DEBUG
if (releaseLog)
{
#endif
va_list argumentList;
va_start(argumentList, format);
NSLogv(format, argumentList);
va_end(argumentList);
#ifndef DEBUG
}
#endif
}
@end
/******
NSLog defines
NSLog works only in the debug mode
To log in release mode, ReleaseLog should be used
******/
#define NSLog(...) SSLog(NO, __VA_ARGS__)
#define ReleaseLog(...) SSLog(YES, __VA_ARGS__)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment