Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to jump to a specific iteration of a loop when debugging?

In Xcode, if I have a for loop that either has a hardcoded limit (i.e. only goes up to 100), is it possible to jump to a specific iteration of the loop? For example, say I have the following loop:

for(int i = 0; i < 100; ++i) {

    [someObject doSomething];
}

If I put a breakpoint before the for loop declaration line, can I somehow go to the 42nd iteration of the loop?

like image 438
pasawaya Avatar asked May 26 '13 23:05

pasawaya


1 Answers

  • One way is to set a breakpoint inside the loop, then do a right click on it and select Edit Breakpoint... In the field called Condition you can write something like i == 50 which means it will stop the first time i equals to 50
  • Second way is to set a breakpoint before entering the loop, run the program, place your cursor above the i-Variable and change its value in the third field of the yellow pop-up
like image 136
JDS Avatar answered Nov 15 '22 08:11

JDS