Last active
March 27, 2024 15:51
-
-
Save pookjw/19d98e67120f49099d9f01e542da8342 to your computer and use it in GitHub Desktop.
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
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