Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var timer: NSTimer?
- var timerStart: NSDate?
- func startTimer() {
- // get current system time
- self.timerStart = NSDate()
- // start the timer
- self.timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("update:"), userInfo: nil, repeats: true)
- }
- func update() {
- // get the current system time
- let now = NSDate()
- // get the seconds since start
- let seconds = now.timeIntervalSinceDate(self.timerStart)
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement