I've been looking through my source code for completion handlers that might benefit from the new async/await features. A few of them are UIKit completionHandlers, e.g. UIViewController#present(animated:completion:)
, and UIViewController#dismiss(animated:completion:)
.
I thought it might be nice to replace code that uses a completion handler for the presentation/dismissal animation with cleaner async/await-oriented code, e.g.
await oldController.dismiss(animated: true)
// now animation is complete, do some cleanup
However, async-oriented functions don't exist for these API's. Their declarations actually include an NS_SWIFT_DISABLE_ASYNC
directive that seems to prevent that from happening.
I was curious why that is. Is it a bad idea for me to write my own async-oriented wrappers for these? Or will they be coming later?
The existence of a modifier explicitly preventing these functions from being generated suggests that maybe there's some fundamental reason that this kind of programming won't work, e.g. a deadlock issue.