Skip to content

Instantly share code, notes, and snippets.

@pookjw
Last active March 27, 2024 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pookjw/19d98e67120f49099d9f01e542da8342 to your computer and use it in GitHub Desktop.
Save pookjw/19d98e67120f49099d9f01e542da8342 to your computer and use it in GitHub Desktop.
import UIKit
enum Hello {
static let foo: Int = {
var result: Int?
if Thread.isMainThread {
result = 300
} else {
DispatchQueue.main.sync {
result = 100
}
}
return result!
}()
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
DispatchQueue.global().async {
_ = Hello.foo
}
DispatchQueue.main.async {
_ = Hello.foo
}
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
view.backgroundColor = .systemOrange // Never Called ㅠㅠ
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment