Reputation: 471
If I init a UIWindow like this:
open lazy var whistleWindow: UIWindow = UIWindow()
I get an runtime issue:
UIWindow() must be called from main tread only
Therefore, I tried to do something like this:
open lazy var whistleWindow: UIWindow = {
var window:UIWindow!
DispatchQueue.main.sync {
window = UIWindow()
}
return window
}()
Sadly I get this error at runtime:
Thread 1: EXC_BREAKPOINT (code=1, subcode=0x10497bba4)
What could I do?
Upvotes: 2
Views: 1327
Reputation: 471
open lazy var whistleWindow: UIWindow = {
DispatchQueue.main.sync {
return UIWindow()
}
}()
Upvotes: 1