Skip to content

Instantly share code, notes, and snippets.

@ivan3bx
Created May 2, 2015 19:34
Show Gist options
  • Save ivan3bx/a6f54400066e079454cb to your computer and use it in GitHub Desktop.
Save ivan3bx/a6f54400066e079454cb to your computer and use it in GitHub Desktop.
Some throwaway code that invalidates an NSTimer, and create a new one for a pseudo-random timeout.
self.timer.invalidate()
let value = ((Float((random()&1000)) / 100) % 5) + 0.4
let rndTimeout = NSTimeInterval(value)
self.timer = NSTimer.scheduledTimerWithTimeInterval(rndTimeout, target: self, selector: Selector("showActivity:"), userInfo: nil, repeats: true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment