Skip to content

Instantly share code, notes, and snippets.

@pixelspark
Created August 6, 2016 21:24
Show Gist options
  • Save pixelspark/bc39f437ef5b306a0d3155e01f93fd3a to your computer and use it in GitHub Desktop.
Save pixelspark/bc39f437ef5b306a0d3155e01f93fd3a to your computer and use it in GitHub Desktop.
public func assertMainThread(_ file: StaticString = #file, line: UInt = #line) {
assert(Thread.isMainThread, "Code at \(file):\(line) must run on main thread!")
}
public func asyncMain(_ block: () -> ()) {
DispatchQueue.main.async(execute: block)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment