Chapter 14. Debugging techniques
This chapter covers
There’s nothing worse than being close to releasing a new application and in your final once-over finding a particularly nasty application crash that seems to have no obvious cause. Even during day-to-day development of your application, it’s unlikely that you’ll write perfect code the first time around, so understanding how to debug your application in the Xcode environment is an important skill.
The Xcode environment integrates a large number of debugging and code analysis tools, but as usual, their true power is only unleashed if you know which tool to use and how and when to use it. A common complaint for new Objective-C developers who are used to managed environments such as C# or Java is that memory management and correct handling of object retain counts (retain, release, autorelease, and dealloc message handling) is hard; so Xcode provides extensive support for detecting and diagnosing memory-related errors.
Let’s create an application and purposely add some errors so that you can discover, observe, and resolve them. The application isn’t overly complex, but it helps demonstrate the debugging tools at your disposal. In Xcode create a new Navigation-based application named DebugSample, and then replace its RootViewController tableview: