Updating the app using async/await
As you have seen previously, the app is unresponsive when the makeToast()
and poachEgg()
methods are running. To resolve this, you will use async
/await
in the app.
Writing the async
keyword in the method declaration indicates that the method is asynchronous. This is what it looks like:
func methodName() async -> returnType {
Writing the await
keyword in front of a method call marks a point where execution may be suspended, thus allowing other operations to run. This is what it looks like:
await methodName()
Important Information
You can watch Apple's WWDC2021 video discussing async/await at https://developer.apple.com/videos/play/wwdc2021/10132/.
You will modify your app to use async
/await
. This will enable it to suspend the makeToast()
and poachEgg()
methods to process button taps and update the user interface, then resume execution of both methods afterward. Follow these steps:
- Modify the
makeToast()
andpoachEgg...