Graphics Programs Reference
In-Depth Information
In
WhereamiViewController.m
, implement this method to log some stuff to the
console.
- (void)doSomethingWeird
{
NSLog(@"Line 1");
NSLog(@"Line 2");
NSLog(@"Line 3");
}
Next in
WhereamiViewController.m
, send this message to the instance of
Where-
amiViewController
in
initWithNibName:bundle:
.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Create location manager object
locationManager = [[CLLocationManager alloc] init];
[self doSomethingWeird];
Finally, drag your breakpoint to this newly-implemented line. Build and run the applica-
tion.
When the execution halts, click the button on the debugger bar to step into this method.
The execution indicator will jump
inside
the
doSomethingWeird
method to the first
line of its implementation. Now click the button to step over a line. The line of code that
logs
Line 1
will execute, and you will see its text in the console.
The execution indicator is now at the statement that logs
Line 2
. If you've decided that
you've seen enough of this fascinating method, you can click the button to step out of it.
Notice that the rest of the log statements appear in the console, and the execution indicator
is now back in
initWithNibName:bundle:
- right after the call to
doSo-
methingWeird
. This behavior is important to understand: when you step out of a meth-
od, you don't cancel its execution; the method finishes normally and returns to the code
that called it.
To remove the breakpoint, simply drag it off the gutter. Or click the icon in the navig-
ator selector to reveal the breakpoint navigator and see all the breakpoints in your project.
From there, you can select a breakpoint and hit the delete key.
Sometimes, a new developer will set a breakpoint and forget about it. Then, when the ap-
plication is run, execution stops, and it looks like the application has crashed. If an applic-
ation of yours unexpectedly halts, make sure you aren't stopped on a forgotten breakpoint.