How to Use the Debugger to Test Your iOS App Code - dummies

How to Use the Debugger to Test Your iOS App Code

By Jesse Feiler

Here is something interesting to look at in the Debugger for your iOS app. As it stands, you can compile your app with no errors and it runs, albeit the same way that it did before. So you have no idea if all that code you added really works. Does it really find the Destination.plist file and create all the dictionaries with their entries correctly?

One way to find out is to put a breakpoint in your code and see what’s there by clicking in the gutter next to (in front of) the line:

_destination = [[Destination alloc]    initWithDestinationIndex:destinationIndex];

Then set another breakpoint:

_subtitle =   destinationLocation[@"Subtitle"];

Run your app.

If your program execution stops at a breakpoint, you can move your pointer over an object or variable in the Source editor to see its contents.

image0.jpg

destinationData is a pointer to the dictionary that contains the data for the first entry in the Destination plist’s DestinationData array. You’ll have six key/value pairs, as you should have, and if you look in the Variables pane in the Debugger, you’ll see two objects in the DestinationsArray, which is also as it should be.

You can explore the display by opening the disclosure triangles to drill down and look at the data.

image1.jpg

You can use the circled i to reveal the contents of the variable.

image2.jpg

Finally, you can use the Quick Look icon to explore the variable and its memory location.

image3.jpg