Bin Chen Bin Chen - 5 months ago 19
Objective-C Question

view the return value of method invocation

How could I view the value of

[fetchedResultsController sectionIndexTitles]
in the debugger without change the code?

return [fetchedResultsController sectionIndexTitles];

Currently, I use to trick of add an tempory variable
and then use "print the descriptions of 's'" command. But this method requires me change the code so it is not convenient.

NSArray *s= [fetchedResultsController sectionIndexTitles];
return s;

Similar, it would be very helpful to be able to see the value of
[a method1]
in following statement:

[b [a method1]]


Do use breakpoints ... Add breakpoint to your return line, right click on breakpoint, edit breakpoint and now you have two options ...

Add Action Debugger Command ...

expr (void)NSLog( @"%@", [fetchedResultsController sectionIndexTitles] );

... or Log Message Action in a similar way and turn on Automatically continue after evaluating.

What it does?

Every time you hit your line with breakpoint, your application is paused, breakpoint actions are processed and as you did turn on Automatically continue after evaluating, your program continues when these breakpoint actions are processed. This is the way how to log, inspect, ..., without modifying your code.