We can make a small change to the SimpleCalc program to demonstrate an index out of range that will cause our
BuggyCalc App to misbehave, but will not automatically display the Debug area. For this type of error, we can create something called a breakpoint
, which will force the Debug area to appear when the error occurs.
In BuggyCalc, select the filename
BTSAppDelegate.m
and set the value ofD_SHOW_DIVIDEBYZERO_BUG
to0
.Add one line of code that uses the compiler directive
#define
to create a symbol namedD_SHOW_INDEXOUTOFRANGE_BUG
with a value of1
as shown in the following code snippet:#define D_SHOW_DIVIDEBYZERO_BUG 0 #define D_SHOW_INDEXOUTOFRANGE_BUG 1
Locate the
- (IBAction)myButtonAction:(id)a_sender
method and add the following lines of code, to create an array of operators, in the method. These should be the first lines of code in the implementation:// Use an array to hold the valid operations NSArray *l_validOperations = [NSArray arrayWithObjects...