Xcode has some good built-in debug tools that can help you find problems. You should get familiar with them.
The Malloc Debug feature will help catch buffer overruns and other memory allocation errors. It works by replacing the system's memory allocators with a (slower) custom version with debugging feature. It makes it more likely that bad memory accesses will cause memory access violations instead of just silently being wrong. (The movie below shows these steps in action).
Click on the active scheme in the window title bar and choose Edit Scheme...
Choose Run, then choose Diagnostics
Under Memory Management, turn on "Enable Malloc Scribble", "Enable Malloc Guard Edges", and "Enable Guard Malloc".
Run your project again.
If you find any errors, congratulations, you've saved yourself some weird crashes. When I'm working on any program, I run with this on 90% of the time.
Look here for more information about Malloc Debug.
In your Xcode project, choose Product->Analyze. This actives a feature of the compiler that will find logical coding errors. In my experience, the things that it points our are almost always either actual bugs or at very least bad coding practice. When I ran it on my Mac OS X port of Invaders, it showed me a leak of a Core Foundation object that I missed.← Prev: iphone-port-pt-3---viewcontroller.m Next: iphone-port-pt-4---touch-handling →