Skip to Main Content
Objective-C® For Dummies®
book

Objective-C® For Dummies®

by Neal Goldstein
October 2009
Beginner content levelBeginner
456 pages
8h 59m
English
For Dummies
Content preview from Objective-C® For Dummies®

Chapter 19. Ten Debugging Tips

In This Chapter

  • Checking for semicolons

  • Watching for lower- versus uppercase terms

  • Paying attention to the first syntax error

  • Recognizing the usefulness of compiler warnings

  • Looking for memory errors

  • Knowing your debugger's features

  • Checking for messages to nil

  • Sending messages to the right object

  • Using NSLog

  • Testing incrementally

  • Solving logic errors

When you're developing an application, there are always a few things that initially don't work out quite the way you planned. That means you will have to go through your code and determine what happened, and more importantly, what to do about it.

Check for Semicolons

Semicolons are the heart and soul of Objective-C statements, and leaving one out can cause incredible havoc. For some reason, forgetting to end a statement with one is something I'm pretty good at. So when I see a lot of errors and warnings, especially if I've just added a few lines of code, semicolons are one of the first things I check.

"Right" Is Not Always "right"

Remember, Objective-C is case-sensitive and For is not the same thing as for. Using the wrong case can send the complier into a tizzy, and while you will get warnings and errors, what you have done may not always be obvious.

When You've Blown It, You've Blown It

It's generally better to ignore the subsequent errors after the first syntax error because they may be the result of that first error. This is especially true when you leave out #import statements (or spell them wrong) or forget a semicolon ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Objective-C

Objective-C

Jiva DeVoe
Cocoa in a Nutshell

Cocoa in a Nutshell

Michael Beam, James Duncan Davidson

Publisher Resources

ISBN: 9780470522752Purchase book