Last active
May 22, 2017 14:37
-
-
Save olxios/c2f8f2920a81c7732de885d547247203 to your computer and use it in GitHub Desktop.
How to use NSLog and print only for debugging? http://swiftiostutorials.com/use-nslog-debugging/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface Log : NSObject | |
extern void SSLog(BOOL releaseLog, NSString *format, ...) NS_FORMAT_FUNCTION(2,3); | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****** | |
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