O'Reilly logo

Beginning iOS 5 Application Development by Wei-Meng Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

DEBUGGING YOUR APPLICATIONS

Debugging your iOS applications is an essential part of your development effort. Xcode includes debugger utilities that help you trace and examine your code as you execute your application. The following sections describe some of the tips and tricks that you can employ when developing your iOS applications.

Errors

When you try to run your application, Xcode first tries to build the project before it can deploy the application onto the real device or Simulator. Any syntax errors that Xcode detects are immediately highlighted with the exclamation icons. Figure B-11 shows an Xcode-highlighted syntax error. The error within the code block is the missing brace symbol ([) for the [[UIAlertView alloc] statement.

image

FIGURE B-11

You can also click the error icon to view the error and let Xcode suggest a fix (see Figure B-12).

image

FIGURE B-12

Warnings

Because Objective-C is a case-sensitive language, a mistake often made by beginners is mixing up the capitalization for some of the method names. Consider the block of code shown in Figure B-13.

Can you spot the error? Syntactically, the statement is correct. However, one of the parameters appears with the wrong case: initwithTitle: was misspelled — it should be initWithTitle: (note the capital “W”). When you compile the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required