Last active
November 1, 2016 15:17
-
-
Save owenzhao/8f4b3a924c3b31ac2fd34c7f6c9f9a3d to your computer and use it in GitHub Desktop.
Use delay to gather files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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