Skip to content

Instantly share code, notes, and snippets.

@gaeng2y
Created March 19, 2025 07:21
Show Gist options
  • Select an option

  • Save gaeng2y/41fbf86b7556990df51f107a648c8d22 to your computer and use it in GitHub Desktop.

Select an option

Save gaeng2y/41fbf86b7556990df51f107a648c8d22 to your computer and use it in GitHub Desktop.
func fetchThumbnails(for ids: [String]) async throws -> [String: UIImage] {
var thumbnails: [String: UIImage] = [:]
try await withThrowingTaskGroup(of: Void.self) { group in
for id in ids {
group.async {
// Error: Mutation of captured var 'thumbnails' in concurrently executing code
thumbnails[id] = try await fetchOneThumbnail(withID: id)
}
}
}
return thumbnails
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment