Skip to content

Instantly share code, notes, and snippets.

@willie-hung
Created September 26, 2023 16:49
Show Gist options
  • Save willie-hung/abe922b5a6fac0b48d779d175e661b52 to your computer and use it in GitHub Desktop.
Save willie-hung/abe922b5a6fac0b48d779d175e661b52 to your computer and use it in GitHub Desktop.
 iOS Interview Prep 7- Async/Await
// 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