2

I want to know how i can trace program execution using xcode I want to know which method being called right now as when you add break point in method

Is there any way to do such alike thing without adding breakpoints??

3 Answers 3

1

There are a couple of Debugger-related WWDC 2012 videos, one of which shows you how to add a breakpoint that continues automatically after running a debugger command. This is preferred to adding logging as there is no need to keep doing the write-compile-debug loop.

You can add an action to the breakpoint that calls:

expr (void)NSLog(@"self=%p Method1", self);

Having said that I still use log calls, but I use my own logging framework which prints the name of the class and method automatically (using __FUNCTION__ string generated by the compiler).

Sign up to request clarification or add additional context in comments.

Comments

1

after search i found that the easiest solution is to put the following code in your methods:

NSLog(@"<%@:%@:%d>", NSStringFromClass([self class]), NSStringFromSelector(_cmd), __LINE__);

Comments

0

NSLog(@"Check 1 - 2 !");

will show you a log trace ;-)

1 Comment

To add to that partial answer. Adding NSLog's within your code will help you to know where your program is at any given point. By putting NSLog(@"<method> fired"); or something similar inside of your methods you will be able to look at your console and see what is happening and when, without requiring you to use breakpoints.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.