-
-
Save romyilano/3c9ce997e2c89ad8f0ef93c479a6f1c5 to your computer and use it in GitHub Desktop.
Revisions
-
acchou revised this gist
Mar 10, 2017 . 1 changed file with 16 additions and 20 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,28 +1,24 @@ import Foundation public func delay(_ delay: TimeInterval, closure: @escaping ()->()) { DispatchQueue.main.asyncAfter(deadline: .now() + delay) { closure() } } #if NOT_IN_PLAYGROUND public func playgroundTimeLimit(seconds: TimeInterval) { } #else import PlaygroundSupport public func playgroundTimeLimit(seconds: TimeInterval) { PlaygroundPage.current.needsIndefiniteExecution = true delay(seconds) { PlaygroundPage.current.finishExecution() } } #endif -
acchou created this gist
May 24, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ import Foundation public func delay(delay:NSTimeInterval, closure:()->()) { dispatch_after( dispatch_time( DISPATCH_TIME_NOW, Int64(delay * Double(NSEC_PER_SEC)) ), dispatch_get_main_queue(), closure) } #if NOT_IN_PLAYGROUND public func playgroundTimeLimit(seconds: NSTimeInterval) { } #else import XCPlayground public func playgroundTimeLimit(seconds: NSTimeInterval) { XCPlaygroundPage.currentPage.needsIndefiniteExecution = true delay(seconds) { XCPlaygroundPage.currentPage.finishExecution() } } #endif