tags:

views:

37

answers:

1

How can I trace the method calls and their sequence while a iPhone app is running? Which Instrument I should use?

A: 

No Instrument does this directly. A couple of options to get this kind of information:

1) Set a breakpoint in the debugger. You can then trace the execution with the "step over" "step into" and "step out" buttons.

2) Put NSLogs at the places in your code that interest you:

-(void) someMethod {
  NSLog (@"Starting someMethod");
  // rest of the method is here
}

You can then read the NSLogs in the console.

William Jockusch
That is fine with situation where I am tracing my own code. Actually, I wanted to delve into a code written by someone else and wanted to understand the code flow. Since it is a huge code base none of these approaches will help me. Any other alternative please?
Abhinav
Diving into other peoples' code is always a challenge. There are no easy answers. In addition to the above techniques, I often try tweaking small stuff to see if the impact is what I think it is. Start with really small stuff like string constants and #defines; then move up to changing utility functions, and from there to the larger methods of the code.
William Jockusch
Using the debugger will work just as well when tracing debug builds with source code written by someone else.
hotpaw2
Thank you so much.
Abhinav