Created
September 26, 2023 16:49
-
-
Save willie-hung/abe922b5a6fac0b48d779d175e661b52 to your computer and use it in GitHub Desktop.
iOS Interview Prep 7- Async/Await
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Call the method | |
fetchImages { result in | |
// 3. The asynchronous method returns | |
switch result { | |
case .success(let images): | |
print("Fetched \(images.count) images.") | |
// 4. Call the resize method | |
resizeImages(images) { result in | |
// 6. Resize method returns | |
switch result { | |
case .success(let images): | |
print("Decoded \(images.count) images.") | |
case .failure(let error): | |
print("Decoding images failed with error \(error)") | |
} | |
} | |
// 5. Fetch images method returns | |
case .failure(let error): | |
print("Fetching images failed with error \(error)") | |
} | |
} | |
// 2. The calling method exits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment