so we can use NSLog to print log.
However, these log information we do not want are still being printed out after the release,
we can define like below in project-Prefix.pch:
1 2 3 4 5 6 7 8 | //enable NSLogs #define DEBUG_MODE #ifdef DEBUG_MODE #define DLog(...) NSLog(__VA_ARGS__) #else #define DLog(...) #endif #define ALog(...) NSLog(__VA_ARGS__) |
use ALog to replace the one you want always be printed.
When you dont need printed DLog,
just comment this line #define DEBUG_MODE.
---------------------- By the way below is something about NSLog's usage -----------------------
In order to track bug occurred,
We can add below at each important function:
- (IBAction)showRangeList:(id)sender { DLog(@"%s Enter", __func__); } |
-[MainViewController showRangeList:] Enter
And NSLog already provide format,
so we don't need code like this:
NSLog(@"%@",[NSString stringWithFormat:@"%@ %@, %@", errorMsgFormat, error, [error userInfo]]); |
NSLog(@"%@ %@, %@",
errorMsgFormat,
error,
[error userInfo]);
|
NSLog([NSString stringWithFormat:@"msg:%@",msg]); |
沒有留言:
張貼留言