1

I placed a breakpoint next to a line of code. I would like to see which lines in my app the compilers will compile next. For example I have this function:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    self.navigationController?.pushViewController(UIViewController(), animated: true)
}

I put a breakpoint inside the function. When I run the app, the compiler stops at the breakpoint. How do I know which lines in my code the compiler will get to next? I understand that there is "Step over" and "Step" into, but I don't think this is what I am looking for. I am trying to debug my app to figure out the cause of a glitch.

2
  • Note that when you're stepping through code, everything has already been compiled. You seem to mean something like: "which line in my app will execute next." Commented May 3, 2017 at 15:54
  • Step into is the right tool. See: developer.apple.com/library/content/documentation/… Commented May 3, 2017 at 15:58

2 Answers 2

2

How do I know which lines in my code the compiler will get to next?

If you want to see where execution continues when the function returns, use the thread step-out or finish command to exit the current stack frame and continue debugging in the calling stack frame.

If you just want to know where execution will continue, you can also use the backtrace command to see the list of stack frames for the current thread. The top frame will be the function that you're in, the next on the list will be the function that called the function you're in, and so on. You can then go to the code for any of the calling functions and set breakpoints if you wish.

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

2 Comments

What does the Step Over do btw?
@nayem step over steps to the next statement without stepping into any function called in the current statement.
0

You need to set the next breakpoints where you want the compiler to stop. If you expect it to go to, say, line 31, you'd have to put your breakpoint there. Having it step over will make the compiler stop at the next breakpoint - being at line 31 in this example.
I don't know of a way to have it automatically stop at the next line it executes.

2 Comments

What if I don't know where it will stop next?
Well it seems like you need to find that out yourself, ha. Maybe there is a way to find that out, but I don't know of one.

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.