How to download images in parallel with Swift Concurrency

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ม.ค. 2025

ความคิดเห็น • 7

  • @israelmanzo8725
    @israelmanzo8725 3 ปีที่แล้ว

    Beautiful .., thanks for this great explanation. Parallel download.. YEA!

  • @truestopguardatruestop164
    @truestopguardatruestop164 3 ปีที่แล้ว +5

    Wait this isn’t fair. You should calculate the time AFTER the try await (so after pokemonData)

    • @swiftandtips
      @swiftandtips  3 ปีที่แล้ว +1

      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! 😃

  • @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 ปีที่แล้ว +1

      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.