I'm used to programming and having log messages be viewable. I know you used to be able to use NSLog()
to trace out messages when debugging Cocoa applications. What is the best way to "trace" messages when coding in an iPhone Xcode development environment?
There's a far more convenient way to trace with log messages in Xcode, and that's using Breakpoint Actions.
On the line of code where you'd be tempted to add a printf or NSLog, set a breakpoint, then control-click it and choose "Edit Breakpoint". In the blue bubble that appears, click the + button on the right to open the Breakpoint Actions: alt text http://idisk.mac.com/cdespinosa/Public/Breakpoint%20Actions.png
Enter your log text there. Any expression that can be printed in the Debugger can be used when delimited by @ signs.
For debugging Objective-C it's generally more useful to choose "Debugger Command" from the popup and enter 'po [[object method] method]' to print the description string of an Objective-C object or the result of a method call.
Make sure to click the "Continue" checkbox at the top right so execution continues after the log.
Advantages of this over NSLog and printf:
Also check out the Speak button; it's great for debugging full-screen apps where you can't see the debug log.