Stop / Pause swift app for period of time

cocoa, nstimer, swift

Solution

The performSelector methods aren't available in Swift. You can get the delay functionality by using dispatch_after.

let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(NSEC_PER_SEC * 1))
dispatch_after(delayTime, dispatch_get_main_queue()){
    changeColourOfPage() 
}

Problem

My app uses multiple threads of `NSTimer` Object. Within the one function (called randomly at random times, not a fixed delay) I want it to pause the whole app, pause the threads for `1 second` only. I have the following code: ``` [self performSelector:@selector(subscribe) withObject:self afterDelay:3.0 ]; ``` Which is objective C, and I tried translating it into Swift like this: ``` self.performSelector(Selector:changeColourOfPage(), withObject: self, afterDelay: 1.0) ``` But I am getting the error `Missing argument for parameter 'waitUntilDone' in call` and when I put that in, it says it wants the argument `modes` but when I put that in it says `Extra argument modes`. I cannot figure out how to pause the app and all it's threads for a couple of seconds, and then carry on like normal? Any ideas?

Original source