-2

I have a while loop thats going too fast so I want to make it happen every second or so. I have this right now:

while (i == 1, ) {
    println("printed")
}
Charles Truluck
  • 961
  • 1
  • 7
  • 28

1 Answers1

2

You can use NSTimer and schedule an action each second:

NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "yourMethodToCall", userInfo: nil, repeats: true)

func yourMethodToCall(){
    println("each second")
}
Christian
  • 22,585
  • 9
  • 80
  • 106