How to download images in parallel with Swift Concurrency

  Рет қаралды 2,843

Swift and Tips

Swift and Tips

Күн бұрын

Пікірлер: 7
@truestopguardatruestop164
@truestopguardatruestop164 3 жыл бұрын
Wait this isn’t fair. You should calculate the time AFTER the try await (so after pokemonData)
@swiftandtips
@swiftandtips 3 жыл бұрын
Hi @TrueStop, well, yes and no hehe. I mean, What was showed is correct, because the idea of async let is to not execute those statements sequentially and that's the point of the timer there, you can see that we reached it very fast, and in a real example, you could call other logic there without waiting for all the images. Maybe the example is too simple and could confuse you, but in this particular case, the time with async let is almost identical to await time, it's clearer to compare what is executed right away after the last async let statement. Anyway, you have a good point. Thank you for your comment! 😃
@israelmanzo8725
@israelmanzo8725 3 жыл бұрын
Beautiful .., thanks for this great explanation. Parallel download.. YEA!
@kigiphoto638
@kigiphoto638 3 жыл бұрын
Nice example, thanks!
@mig12394
@mig12394 3 жыл бұрын
Thanks for your tutorial but I have this error a server with the specified hostname could not be found pokeres.bastionhot.org/images/pokemon/1.png
@swiftandtips
@swiftandtips 3 жыл бұрын
Hi @michel, thanks for the comment. I realized that after my demo that url didn't work anymore. I just updated the repo with a new URL that works :) github.com/pitt500/Async-Let
@BlumeAbra
@BlumeAbra 2 жыл бұрын
Awesome video. '?' mark is not printed. If print("Downloaded") and print("Downloading..") are kept between lines 36/37 and between lines 38/39, only "Downloaded" is printed. Need to clarify and check on one aspect. Tasks are spawned concurrently, all of them finish downloading, then only parent View is updated. This would be wrong if set of images is larger, say 200. It should act somewhat similar to - as user is scrolling (in say LazyVStack), network calls are made to fetch more images and populate parent View. How would that be accomplished - what would be solution scheme? What is needed is: as downloads are happening and finishing, it should update the parent View. Downloaded images should show up in LazyVStack, and those which are not yet downloaded should show with '_downloading_' or say '?' mark.
Mediator Pattern in Swift: Explaining a Real-World Example from My Job
24:16
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН
小丑教训坏蛋 #小丑 #天使 #shorts
00:49
好人小丑
Рет қаралды 54 МЛН
Xcode 16’s New Folder Format Explained! No More Merge Conflicts!
7:32
The Biggest React Framework You've Never Heard of
20:29
Theo - t3․gg
Рет қаралды 51 М.
Is TCA a Good architecture?: Insights from a Principal Engineer
6:35
Swift and Tips
Рет қаралды 3,6 М.
Avoid THIS Animation Glitch When Hiding TabBar in SwiftUI
11:03
Swift and Tips
Рет қаралды 1,3 М.
Testing 101: What Are UI Tests & How to Write Them in Swift/iOS
50:33
Swift and Tips
Рет қаралды 1,1 М.
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН