0

I am trying to create a simple and neat function that uses NSTimer to add a delay to what is ever in the brackets. For e.g.

 func Adddelay(delay:Double, closure:()->()) {
  //Code in here using NSTimer that will add a delay for as long as stated in delay (the number passed in)
    }

From this, i am trying to aim to use it by going:

delay(1){
//Code in here that will execute after a delay of one second
}     

The function NEEDS to use NSTimer for what i am using it for as a whole.

Any help will be greatly appreciated.

JohnnyCash
  • 67
  • 1
  • 5
  • 1
    What's wrong about http://stackoverflow.com/a/29338910/1187415 ? – Martin R Apr 01 '15 at 05:05
  • It does work fine but I understand NSTimer and know how to utilities it for what I need, I just need help turning it into a simple function for easier use. – JohnnyCash Apr 01 '15 at 05:57

1 Answers1

1

in your case, you need to use extension for NSTimer. Published on gist: https://gist.github.com/dimpiax/e2adc74c25d76d124fc3

Update:

Published lib: https://github.com/dimpiax/RichTimer

dimpiax
  • 12,093
  • 5
  • 62
  • 45