Game Development Reference
In-Depth Information
An assertion is said to have failed when its condition evaluates to false ( NO ). The
NSAssert macro then raises an exception, which causes Xcode to halt program execu-
tion to show you the offending line of code—much like in Figure 14-5 .
Assertions are evaluated only in debug builds. Still you ought to limit the use of assertions
in code that runs every frame because this can slow down your app in debug builds. You
can switch between Debug and Release build configurations by choosing Product
Scheme Edit Scheme in Xcode. Then select the Run profile, where you'll find the
Build Configuration setting on the Info tab.
Caution Since assertions are evaluated only in debug builds, it is crucial to
avoid running any code or calling any method in the assertion's condition that
alters the program state. Otherwise, the program will behave differently in de-
bug and release builds.
Adding Breakpoints
Breakpoints enable you to halt (pause) program execution at a specific line of code. Op-
tionally, you can edit conditions that need to be met for the breakpoint to trigger.
You can easily add and enable or disable a breakpoint by clicking on the gray vertical area
to the left of the source-code editing window. If you have line numbers enabled in Xcode
( Xcode Preferences Text Editing Line numbers ), that's where the line numbers
are shown. In Figure 14-6 , a breakpoint was added in line 103. The app ran until the line
of code with the breakpoint was reached, and then it halted. The line that will be executed
next is highlighted with a green tint—that's the execution pointer.
Search WWH ::




Custom Search