Skip to content

Instantly share code, notes, and snippets.

@owenzhao
Last active November 1, 2016 15:17
Show Gist options
  • Save owenzhao/8f4b3a924c3b31ac2fd34c7f6c9f9a3d to your computer and use it in GitHub Desktop.
Save owenzhao/8f4b3a924c3b31ac2fd34c7f6c9f9a3d to your computer and use it in GitHub Desktop.
Use delay to gather files
var rawFilenames = [String]()
// instance counter
var timer:NSTimer! = nil
func application(sender: NSApplication, openFiles filenames: [String]) {
if shouldQuitAppAfterConvert == nil {
shouldQuitAppAfterConvert = true
}
if timer != nil {
timer.invalidate()
}
self.rawFilenames += filenames
timer = NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector: #selector(prepareConvert), userInfo: nil, repeats: false)
}
func prepareConvert() {
// do something
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment