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
I notice that the edit breakpoints feature, while useful and perhaps modern, does not commit to source control, so does not scale to a team of developers. For this reason, I would say that when working on a team under source control to stick with code-based logging such as 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.
Here is a similar solution using NSLog
, which might be fewer characters than the other solutions.
However, unless you add the void
like this:
po (void)NSLog(@"the person name is: %@", p.name)
you will get an annoying "nil" printed out with your log. for example:
(lldb) po NSLog(@"foo")
nil
2013-06-19 14:42:59.025 TheMove[95864:c07] foo
(lldb) po (void)NSLog(@"foo")
2013-06-19 14:43:10.758 TheMove[95864:c07] foo
If you can live with the nil (I can) it's faster to type and easier to remember just the po