Wednesday, August 11, 2010

Josh Highland: Don't use NSLog anymore!

Azt irja, hogy nem engedik be az app store-ba azokat az appokat amikben van NSLog.

Helyette ezt javasolja:

add the following lines to the Prefix.pch file:

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define DebugLog( s, ... ) NSLog( @"<%@:(%d)> %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
#define DebugLog( s, ... )
#endif

In your code, replace “NSLog” with “DebugLog”. THATS IT!
DebugLog adds some new functionality to NSLog. It will now output the file name and line number of the Debug statement.
The best part of this is that its very easy to disable when its time to create a release build of your code. Simple comment out the “#define DEBUG_MODE” line im the “_Prefix.pch” file.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.