title: Do something every nth iteration of loop in Objective-c or Swift
body: <p>Within a loop, it is possible to do something every other time by using odd and even and testing for even. I would like to do something a fixed number of times eg four  no matter how many iterations there are in the loop (value of i). Is there a way to do something every nth time?</p>
  <p>I think there must be a way by incrementing a second counter, but having trouble getting it.</p>
  <pre><code>A Loop
  int i = 0;
  int movinglimit = 0;
  int incr = [myItems count]/4;;// there might be 10, 20 or 30 items. I only want to do something four times
  while (i &lt; [myItems count]) {
      
  if ((i % 2) == 0) {
      
  //do something if even
  }
  
  
   if (i&gt;movinglimit) {
          //do something a total of four times
   }
   if (i==moving limit+1) {
              movinglimit = movinglimit + incr;
   }
      i++;
   }
  </code></pre>