Conclusion
Congratulations! You just completed your first refactor using async/await, and that’s just the beginning.
In this lesson, you learned:
- How complex callback chains can make code difficult to read and maintain. With async/await, you can write asynchronous code that looks and behaves much like synchronous code, making it more intuitive and easier to understand.
- The
async
keyword is a powerful tool in Swift for defining asynchronous behavior across various types of objects, allowing you to leverage modern concurrency features. - The
await
keyword acts as a synchronization point in asynchronous code, ensuring that the program proceeds only when the awaited operation has finished its task.
The next lesson will be all about the new URLSession
asynchronous API,
so get ready to embrace a sleek, modern approach to handling network requests in Swift.