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?
Navigate to a line in your code where you want execution to pause, then click the gutter or line number in the source editor to set a breakpoint. Xcode displays a breakpoint icon to indicate the location. Drag a breakpoint up or down to move it to another location; drag it away from the gutter to remove it.
You can set a conditional break point in Xcode by setting the breakpoint normally, then control-click on it and select Edit Breakpoint (choose Run -> Show -> Breakpoints). In the breakpoint entry, there is a Condition column. Now, there are several issues to keep in mind for the condition.
Print a variable Click the Add Action button and select Debugger Command. Put any print command in a debug console in a text field. Make sure you prefix it with po , e.g., po print(view) .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With