Skip to content

Instantly share code, notes, and snippets.

@olxios olxios/Log.h
Last active May 22, 2017

What would you like to do?
How to use NSLog and print only for debugging?
#import <Foundation/Foundation.h>
@interface Log : NSObject
extern void SSLog(BOOL releaseLog, NSString *format, ...) NS_FORMAT_FUNCTION(2,3);
#import "Log.h"
@implementation Log
void SSLog(BOOL releaseLog, NSString *format, ...)
#ifndef DEBUG
if (releaseLog)
va_list argumentList;
va_start(argumentList, format);
NSLogv(format, argumentList);
#ifndef DEBUG
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
You can’t perform that action at this time.