I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\
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
#define LOG_DEBUG | |
#define __PREPEND_DATE(format) ([NSString stringWithFormat:@"[%@] %@", [[[NSDate new] description] componentsSeparatedByString:@" "][1], [@"%@" stringByAppendingString:format]]) | |
#define SLog(args,...) do { [[NSFileHandle fileHandleWithStandardOutput] writeData:[[NSString stringWithFormat:__PREPEND_DATE(args), @"", ##__VA_ARGS__] dataUsingEncoding: NSUTF8StringEncoding]]; [[NSFileHandle fileHandleWithStandardOutput] writeData: [@"\n" dataUsingEncoding: NSUTF8StringEncoding]]; } while(0); | |
#ifdef LOG_DEBUG | |
#define NSLog SLog | |
#endif | |
// ALog always displays output regardless of the DEBUG setting |