Skip to content

Instantly share code, notes, and snippets.

@tokizuoh
Last active April 13, 2024 14:32
Show Gist options
  • Save tokizuoh/b8eaa170a05bcbfaa98cd7cc08e5c42e to your computer and use it in GitHub Desktop.
Save tokizuoh/b8eaa170a05bcbfaa98cd7cc08e5c42e to your computer and use it in GitHub Desktop.
import UIKit
class ViewController: UIViewController {
var callback: () -> Void = { @MainActor in
print(Thread.isMainThread) // true or false?
}
override func viewDidLoad() {
super.viewDidLoad()
Task.detached {
await self.callback()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment