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?
Another way in Swift 3.1
You can substitute other units like
.milliseconds(1000)
or.microseconds(1_000_000)
or.nanoseconds(1_000_000_000)
for the time interval.The performSelector methods aren't available in Swift. You can get the delay functionality by using dispatch_after.
Sorry to answer an old question, but just came along a better way to do this -