I have several cases in my apps where asynchronous behavior could lead to a situation where dismiss() is called a very short time after calling present().
Consider this code sample to illustrate:
let alert = UIAlertController(title: "title", message: "message", preferredStyle: .alert)
self.present(alert, animated: true, completion: nil)
[ do some work here ]
alert.dismiss(animated: true)
The amount of time between the present() and dismiss() could be long or short, possibly less than a millisecond if there is no work to do. If the work is completed immediately will it result in a runtime error?
If the call to dismiss() should be delayed until the presentation is complete, how would I code that?
Consider this code sample to illustrate:
let alert = UIAlertController(title: "title", message: "message", preferredStyle: .alert)
self.present(alert, animated: true, completion: nil)
[ do some work here ]
alert.dismiss(animated: true)
The amount of time between the present() and dismiss() could be long or short, possibly less than a millisecond if there is no work to do. If the work is completed immediately will it result in a runtime error?
If the call to dismiss() should be delayed until the presentation is complete, how would I code that?