I'm thinking about two scenarios:
(1) I want to present a dialog (let's say, a data collection form). So I write a function:
func myForm(_ inData: MyDataStruct, completion: (()->MyDataStruct)?)
which instantiates a view controller, presents it, and calls the completion handler in response to Save or Cancel buttons. This can presumably be converted to async/await using withCheckedContinuation.
If I understand things correctly, this would result in a function:
func myForms(_ inData: MyDataStruct) async -> MyDataStruct
(BUT [Q]: [or at least a subject for my own experimentation] what happens if the dialog is dismissed with a swipe (i.e. by some user action other than tapping one of the "expected" buttons?) — how does continuation.resume get called in this case?)
(2) I want to present an alert (using UIAlertController) and wait for it to return before continuing. Do I handle this the same way? (I.e., wrap it in a call to withCheckedContinuation)?
This is my first foray into async/await, and I'd appreciate a bit of support (even if just in the form of "yes, that's the way to go") before I spend time getting lost in the weeds.