how to create a breakpoint's log message action in xcode?
Been watching a WWDC video today about new features in xCode 4. They have mentioned that it a good idea to use log message actions on breakpoints along with "automatically continue after evaluation actions" enabled to output a variable's value for instance instead of using NSLogs all the time.
lets say I have something like that:
NSLog(@"URL is : %@", userDocumentsURL);
How would I write a log message action to display userDocumentsURL's value? Is it really a good idea to use the above method instead of NSLog?
Create a Breakpoint 'Log Message' action. For the log message include something like:
URL is @(char*) [[userDocumentsURL description] UTF8String]@
Alternatively you can create a breakpoint 'Debugger command' action similar to:
po [NSString stringWithFormat:@"URL is: %@", userDocumentsURL]
I prefer using breakpoint actions for logging, as it's arguably easier to clear out a bunch of breakpoints than it is to remove NSLogs. A possible downside to using breakpoints in this fashion is that they are significantly slower (during debugging) than a direct NSLog.