We can make a small change to the SimpleCalc program to demonstrate an integer division by zero that results in the Debug area appearing while the program is running.
Create a new Xcode project (we can follow the steps given in Chapter 1, Our First Program – SimpleCalc) but call it
BuggyCalc
instead ofSimpleCalc
. Other than the App name being BuggyCalc, all the steps are the same as was done for SimpleCalc.In BuggyCalc, select the filename BTSAppDelegate.m and add the following line of code that uses the compiler directive
#define
to create a symbol namedD_SHOW_DIVIDEBYZERO_BUG
with a value of1
:#define D_SHOW_DIVIDEBYZERO_BUG 1