One Quickie


Using NSTimer (NSTimer->Swift)
    var sessionTimer: NSTimer?

...
        sessionTimer = 
            NSTimer.scheduledTimerWithTimeInterval(0.5, target: self, 
                                                   selector: #selector(SessionEditorViewController.lubDub(_:)), 
                                                   userInfo: nil, repeats: true)
...

    func lubDub(timer: NSTimer) {
        let elapsedTime = NSDate().timeIntervalSince1970 - startTime
        print("(elapsedTime)")
    }
...

    // clean up when done
        sessionTimer?.invalidate()
        sessionTimer = nil



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com