What are some Objective-c debugging tips?

debugging, objective-c

Solution

Asserts. Lots and lots of asserts. When you assume something must be some way, assert that it is true.

Build & Analyze is the new Build. Use the Clang Static Analyzer in Snow Leopard.

There is no magic; everything on your system and in your code happens for a reason, including crashes & misbehavior.

Embrace the debugger; it is really powerful and quite easy to start using.

Greg Parker's weblog is a wonderful source for a "behind the curtains" view of how some things work: http://www.sealiesoftware.com/blog/

Problem

I'm still haven't properly learned how to use the Xcode debugger, but I was wondering if anyone has some favourite debugging tips, things you can quickly insert into code to see the state of objects. Anything which would help me get more of a grasp on the internals of Objective-c. Mostly I rely on `NSLog(@"%@", myObject)` to see what's happening with myObject, or sometimes `NSLog(@"%@", [myObject class])` to check that something is really the class it should be. I know that I can do both by using the debugger, but I want to try using code for the moment, before I take the leap into using a full debugger. Do you have any similar tricks?

Original source

Related problems