Game Development Reference
In-Depth Information
Chapter
14
Debugging & Best Practices
Debugging is the art of understanding the root causes of a programming or specification is-
sue so that you can either fix the issue, work around it, or alter your program specifications
and requirements.
Why mention this at all in a topic about SpriteBuilder?
Because you'll inevitably run into problems that you can easily solve on your own with just
basic knowledge of debugging tools and techniques. These problems are logging, asserting,
adding breakpoints, stepping through code, and inspecting variable values. The latter two
are performed while your app is running, which allows you to see exactly which paths your
code is taking.
In this chapter, I give many code examples you don't need to add to your Xcode project.
The code provided here serves as debugging examples, but it doesn't add anything of signi-
ficance to the Bouncy Beast project itself.
Tip You'll find a lot more detailed explanations about debugging apps with
Xcode in the Apple developer library: https://developer.apple.com/
library/mac/documentation/ToolsLanguages/Conceptual/
Xcode_Overview/DebugYourApp/DebugYourApp.html .
Logging Messages and Variables
Logging means printing a text string to the Xcode debug console. Logging can be effective
in printing out values of variables, especially if these values change over time. It is often
used together with marking the flow of program execution, meaning when specific code
runs in time relative to other code.
You have used NSLog before—for instance, in MainMenuLevelSelect.m , to log whenever
the CCScrollView delegate methods fire. Listing 14-1 shows one use of NSLog .
Search WWH ::




Custom Search