简体   繁体   中英

Debugging with breakpoints in Xcode

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM