Trying to set an image on a button when tapped. Verified that the targetAction handler is always invoked on the main thread.
This doesn't work
@objc func buttonTapped() {
self.mybutton.imageView?.image = MyObjcClass.getImageNamed("DarkVersion")
}
But this works:
@objc func buttonTapped() {
DispatchQueue.main.async { // Does not work without this dispatch
self.mybutton.imageView?.image = MyObjcClass.getImageNamed("DarkVersion")
}
}
On the debugger I can see that both are on the main thread