Reputation: 147
I'm trying to figure out how to determine what the next method call will be in Xcode if I have a breakpoint set at a particular line of code. Is there a way you can tell what method is executed next? The problem with using "Step Over" is that sometimes it switches into that screen (I don't know what it's called) that shows you the hexadecimal values. I'm guessing it's some sort of screen showing you the byte code? I'm not sure how to get around that and go to the next method in the chain.
Upvotes: 0
Views: 283
Reputation: 318824
Simply look at the stack trace on the left side of the screen. The topmost line (line 0) is the function that you are currently in. The next line below that (line 1) is the function that called the current function and it's the one you will return to when the current function is done.
Look at that stack trace. Notice how some lines are bold and some are not. The lines in bold are functions that you have the source code for. Either code you wrote or code you have from any 3rd party libraries you are using.
If you are stepping through some of your own code and you get to the last line of the function, look at the stack trace. Look at line 1. Is it bold or not? If not, then there is no source code and if you enter that function you will see the assembly code (all that hexadecimal stuff).
Let's say line 0 (your current function) is your own code. Then you see that line 1 and maybe 2 is not in bold, but line 3 is and you want to get to your code in line 3. Click on the "step out" up arrow ( ↥ ) to finish the current function. That will take you to the line 1 (now it becomes line 0). Now you are in the assembly code. Just tap the "step out" button again. Tap it again until you get back to your own code again.
Just look at the stack trace to see where each click of "step out" will take you next.
The picture below is an example. Look at the stack trace. Line 0 is the function I'm currently in. It's named effective
in my ViewController
class. Note it is bold. Line 1 is the function that called line 0. Line 1 is my cellForRowAt
method. It is also in bold. The debugger is currently on the last line of the effective
method. If I do either "step over" or "step out" at this point, I will be leave the effective
method and return to the point where it was called. Line 1 shows where that is. Since line 1 is in bold I know I have the code for it.
Once you leave the current function and return to the previous function, all of the lines in the debugger shift up. Line 1 becomes line 0. Now I know that when I leave my cellForRowAt
method, I would be taken into code I don't have the code for (since that line in the stack trace isn't bold). In fact, as you can in the stack trace, there are no more bold lines until the stack trace returns all of the way back to main
. So unless you want to see lots of assembly code, once you finish debugging in cellForRowAt
, you may as well click the "continue program execution" button.
Upvotes: 1