1

I have code that contains a nested for loop, and I need to see the execution line by line so I can understand how the loop works.

When running the program, I need to press "enter" to execute the next line. I remember about a month ago I accidentally found it, I kept pressing "enter" until the last line was executed but unfortunately I forgot how. What is the procedure for doing this?

jscs
  • 63,694
  • 13
  • 151
  • 195
user2066392
  • 341
  • 1
  • 2
  • 11
  • 1
    Have you tried using the controls in the debugger area? There are buttons for pausing, step into, step over and step out. The are the buttons on top of the debugger area – DominicanCoder Mar 02 '14 at 19:39
  • 1. Set breakpoint at the start of the code you would like to step through (Command+\\). 2. Run the program (Command+R). 3. Step over each instruction (F6). – Till Mar 02 '14 at 19:40

1 Answers1

1

You need to use a breakpoint.

It is an indication to the debugger that it should stop the execution of your app (in debug mode) when the execution reaches this point (you can also add conditions).

When it stops, what to do is up to you:

  1. continue program execution
  2. step over
  3. step into
  4. step out

Try it, you will love it. Set a breakpoint, and when execution stops, go to the Xcode "Debug" menu.

jscs
  • 63,694
  • 13
  • 151
  • 195
Armand DOHM
  • 1,121
  • 1
  • 7
  • 9