How to use Continuations in Swift (withCheckedThrowingContinuation) | Swift Concurrency #7

Поделиться
HTML-код
  • Опубликовано: 28 ноя 2024

Комментарии • 41

  • @lucagfc
    @lucagfc Год назад +3

    These videos and your whole channel is amazing. Simple, straightforward explanation about something that actually IS complicated! Thanks for your work!

  • @krutomjer
    @krutomjer Год назад +2

    Happy New Year and thank you for these tutorials. It's Jan 1st 7am where am at and your videos are the first thing I'm watching starting 2023.

    • @SwiftfulThinking
      @SwiftfulThinking  Год назад +1

      It’s 3am here! Let’s go 🚀🚀🚀
      Happy New Year 🤙

  • @ObinnaAguwa-n5x
    @ObinnaAguwa-n5x Год назад +1

    Thank you Nick. I saw this in a codebase recently and had zero idea of what it means or does. You are a life saver.
    Anyway, it is the "get rid of this nonsense" for me at 20:56, Lmao!

  • @richardhasson265
    @richardhasson265 2 года назад +3

    Thanks for breaking this stuff down so well. It's finally starting to gel a bit in my mind. I have several functions with completion handlers in project that are called in sequence (ex: sequential alerts and completion handlers after animations) that will really benefit from this type of conversion to more linearly readable code. Much appreciated!

  • @amith2947
    @amith2947 2 года назад +1

    after a long time, I come back to your videos, u look good my g!!! I like ur hairstyle

  • @danielcrompton7818
    @danielcrompton7818 16 дней назад

    2:54 -- You don't need the do-catch at all -- you can just use try not in do block in a sthroign function as the error will bubble up til when the function's errors are handled

  • @lincolndickerson1293
    @lincolndickerson1293 2 года назад

    As always fantastically simple representation of what tends to be a confusing topic. On thing I might do for readabilty is use two guards instead of if, else if, else. But this is very much a personal preference thing.

  • @josemanuelortizsanchez4983
    @josemanuelortizsanchez4983 2 года назад +1

    Awesome video on how to reuse legacy code with our new async model. Thank you!

  • @Y0sid0
    @Y0sid0 2 месяца назад

    Wonderful explanations, much thanks ^^

  • @ПогореловИван-ж1р
    @ПогореловИван-ж1р Год назад +2

    You are beautiful!
    Thanks for your work❤️
    Hugs from Ukraine 🇺🇦

  • @keithweiss229
    @keithweiss229 2 года назад +1

    Awesome Job Nick!

  • @tbg6nb
    @tbg6nb 2 года назад +1

    amazing content, straight to the point and simple examples

  • @nithyavasudevan
    @nithyavasudevan 9 месяцев назад

    In the previous videos - when we add the downloaded images to the [UIImage] array - why is it not necessary to do it in the main thread (Main Actor) ?
    Truly fantastic and educational videos BTW.

  • @光莒
    @光莒 2 года назад +1

    It's amazing video again!!
    You always let us easily to know the complicated things~~
    thanks you so much

  • @maciusessa
    @maciusessa 2 года назад +2

    So.....this is basically alternative to using Combine?
    Interesting playlist but i remember that on Intermediate Playlist you said that Combine is the future of Swift. Is Concurrency actually better than Combine? When to use each of them? Is the performance difference that significant?
    Great playlist, tho. Learning a lot of new cool stuff!
    One more question. What do you think about Reactive Programming with f.ex RxSwift? Do you use that? Is it worth putting time on learing RxSwift?

    • @SwiftfulThinking
      @SwiftfulThinking  2 года назад +3

      Great questions, and I think the answer is basically chronological. RxSwift is a way of doing reactive programming and was introduced before Combine existed. I believe RxSwift supports iOS 9, while combine is only available iOS 13 and higher. If you’re working with SwiftUI, Combine is likely the way to go for reactive programming. Combine was introduced before Swift Concurrency existed. Now that we can use this, I’d say this is the best way to do asynchronous programming in Swift! In the final video of this series I take a few minutes to explain how Apple seems to be replacing Combine completely with Swift Concurrency features (although it’s not 100% there yet) 😜

    • @maciusessa
      @maciusessa 2 года назад

      @@SwiftfulThinking thanks for answer. I Get The point, but for newcomer in iOS development it might be confusing. What to learn? Combine? RxSwift? Concurrency? Optimal answer would probably be Concurrency but employers still look for skills in older Frameworks. Which framework would You recommend to learn first and use in portfolio apps?

  • @BABEENGINEER
    @BABEENGINEER 6 месяцев назад

    Great explanation!

  • @danielcrompton7818
    @danielcrompton7818 4 месяца назад

    Would it be a good idea to make a continuation from the Data.write(to:) function which may take some time?

  • @jasondhindsa6774
    @jasondhindsa6774 2 года назад

    Nick, are you able to do a video on Swift metatypes?

  • @fernandoivanperezruiz5144
    @fernandoivanperezruiz5144 Год назад

    Amazing video! I was really struggling getting my head around continuations. Just one quick question, I've read somewhere that after resuming a continuation we should set it to nil, is that true? And if so, why? Thanks!

  • @vimak
    @vimak 2 года назад

    So juicy content.Thanks a lot 🙌

  • @tokero5199
    @tokero5199 2 года назад +1

    Very nice series here. I'm learning a lot. Your GetData function at 5:23 could actually be a one liner like this:
    func getData(url: URL) async throws -> Data {
    try await URLSession.shared.data(from: url, delegate: nil).0
    }

  • @emirhan1356
    @emirhan1356 3 месяца назад

    awesome videos, much thanks

  • @moalsamman
    @moalsamman 2 года назад +2

    Hi Nick thanks for the amazing content and your great explanation skills.
    Is there a way to convert a function that its completion handler returns twice? for example in AWS AppSync the completion handler returns the cached data then returns again the updated data from backend I tried withCheckedContinuation but I got an error that it must resume only once. Thanks :)

    • @SwiftfulThinking
      @SwiftfulThinking  2 года назад

      No, not that I know of at least. I’ve had the same problem with some Firebase calls and have just been keeping those functions as completion handlers for now. One hacky solution would be to set up an @Published variable, have the completion handlers update the publisher, and separately have your await functions pointed to the publisher.

  • @cinquain0
    @cinquain0 2 года назад +1

    Good stuff!

  • @박성수-u3v
    @박성수-u3v Год назад

    perfect video I've ever seen..!!

  • @SiamakAshrafi
    @SiamakAshrafi 2 года назад +1

    Almost all the APIs are now async but it is very easy to convert if they are not. No reason to keep using GCD.

  • @asadchattha3470
    @asadchattha3470 8 месяцев назад

    Thanks for wonderful effort

  • @MauricioChavesDias
    @MauricioChavesDias 2 года назад

    Amazing content! Thanks for sharing that with us :-)

  • @obsessed92
    @obsessed92 2 года назад

    Hi Nick. Quick question, func getHeartImageFromDatabase() async -> UIImage doesn't use .resume() at the end. Could you tell me why is that ? Great content as always, thank you for your work.

    • @gurcangulec
      @gurcangulec Год назад

      Hi, you must have figured it out by now but for those who are wondering the answer for this question is that we need to call resume() method at the end of a URLSession.shared.dataTask for it to start working. We don't have a URLSession inside getHeartImageFromDatabase() so we don't need that like we did in getData2().

  • @pasha7324
    @pasha7324 Год назад

    🔥

  • @mhmtkrnlk
    @mhmtkrnlk 2 года назад

    Cant wait to go home

  • @cckelay
    @cckelay 11 месяцев назад

    thanks

  • @KulturanCov
    @KulturanCov 2 года назад

    gooodddddddd