I know that we have to call the main thread when we update the UI. But I can't explain my teammates why we have to do it and why Swift doesn't do it automatically.
They used to call self.present() like this:
self.present(alert, animated: true)
But I know you should call it this way:
DispatchQueue.main.async {
self.present(alert, animated: true)
}
I actually would like to make sure the method is always called on the main thread but I don't know how... The other question is: Why do I have to make sure this method is called on the main thread and not Swift? There always is an UI update when someone calls this method.
@available(iOS 5.0, *)
open func present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil)