title: XCode 6 - Delay iterations in a loop?
body: <p>I am testing a basic animation using a while loop. When the user touches a start button, an image randomly appears with every click of the button. I then placed the same code within a while loop and the image does not seem to move. I am thinking that it is just moving too fast through the iterations and therefore appears to not be moving. So, is there a way, simple or otherwise, that I can delay the speed of the loop so I can see a transition to some degree? I'm thinking that the speed of the loop is what is doing this, as text is instantly outputted to the label, thus I know the loop is working at least. Here is what I have...</p>
  
  <pre><code>@IBAction func btnStart(sender: AnyObject) {
  
      isMoving = true
      var i = 0
      while (i != 200) //arbitrary number of iterations chosen for this example
      {
          var x = arc4random_uniform(400)
          var y = arc4random_uniform(400)
          myButton.center = CGPointMake(CGFloat(x), CGFloat(y));
          ++i
          lblHitAmount.text = String(i) //200 appears instantaneously in label, loop is working
     }
   }  
  </code></pre>
  
  <p>EDIT:</p>
  
  <pre><code>var timer = NSTimer()
  var counter = 0    
  
  timer = NSTimer.scheduledTimerWithTimeInterval(0.5, target: self, selector: Selector("tolabel"), userInfo: nil, repeats: true)
  
  
      var i = 0
      while (i != 800)
      {
          var x = arc4random_uniform(400)
          var y = arc4random_uniform(400)
          btnBug.center = CGPointMake(CGFloat(x), CGFloat(y));
          ++counter
          ++i
  
          //lblHitAmount.text = String(i)
  
     }
  
  func tolabel(){
      lblHitAmount.text = String(counter++)
  }
  </code></pre>