How to use escaping closures in Swift | Continued Learning #20

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

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

  • @j1nMatt
    @j1nMatt 3 года назад +25

    Your tutorials are very practical compared to others, specially for people coming from other programming languages

  • @EssaAlshammri
    @EssaAlshammri 3 года назад +5

    I’ve seen like 5 videos about escaping but this one sank in easily 👍 thanks

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

    Best explanation about escaping 🤩👏

  • @muhammadnasser2735
    @muhammadnasser2735 3 года назад +3

    i love you man you make the swiftUI so easy

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

      Haha Thanks Muhammad.. but it's not me. It's Apple that made SwiftUI so easy 😎

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

    Well explained. Thank you so much.

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

    I really felt like I got a handle on escaping for the first time, thanks very much for the clear explanation! Briefly included in here was an example of your approach to closures. I think I have a mental block for closures, as I've reviewed them dozens of times and momentarily felt like I almost understood them, only to have the understanding slip away again. I guess what I'm wondering is whether there is a way to know, in this video for example before you introduce the asynchronous task in downloadData3, how to decide upon when and how to use closures and completion handlers. In any case, keep up the great work, I really appreciate your effort and attention to detail!

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

    Your lessons are excellent!

  • @sheetalpahadi
    @sheetalpahadi Месяц назад

    Very very informative

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

    lol.. love how you called "we went from this ugliness here" hahaha 🤣. Amazing tutorial as always Nick, Thanks!!

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

    Wow, very concise and explained extremely clear

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

    This is the only video i had watch twice to understand. Thanks nick..... ❤️✌️

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

    Another very well explained video!

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

    Well explained. ✅

  • @a4advanture755
    @a4advanture755 3 года назад

    super video .. very welll explained

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

    ... after 14 minutes we saw the first example of code with escaping 🥳

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

    Quite a clear explanation. Thanks a lot!

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

    Well presented, but it still makes my head spin.

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

      Thanks Pitmanra. Don't stress about this one too much, we're going to be using Combine most of the time anyway! You'll grasp this pretty easily when we start using it in apps :)

  • @ЕнСобЛи
    @ЕнСобЛи 3 года назад +1

    you are the best! Thank you so much

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

    Had to run through this a few times. Struggle with this - my bad - not bright enough!

  • @mig12394
    @mig12394 3 года назад +3

    more and more difficult, but well explained

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

      We have to get into the hard stuff sooner or later haha Thanks again for the comment.

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

    Thanks Nick! this tutorial really do helped me! By the way, I come to curious about a completion handler. As soon as completion handler is called, I understood that the bracket in the upper? function(like getDat function in the video) is called. Than, can I do something AFTER the completion function is completed? Like, writing more code after completionHandler("new data!") block in func downloadData2 Anyway, really easy and good tutorial!

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

    Crystal clear

  • @coffeeCatPeanutDust
    @coffeeCatPeanutDust 3 года назад +1

    Hey Nick. I noticed something that's been reoccurring in a few of your videos and I'm guessing it's just an xcode update, but at 9:41 when you hit enter on the completions, xcode seems to add in parenthesis, whereas in mine, it does not. It doesn't seem to make a difference but still... Are the parenthesis unnecessary?

  • @Jeff-zc6rr
    @Jeff-zc6rr 7 месяцев назад +3

    But then what is the difference between this and async? It seems there are two options to do things asynchronously.

    • @SwiftfulThinking
      @SwiftfulThinking  7 месяцев назад

      Yes, there are 3 main ways actually. Using @escaping closures was the first evolution of Swift, then came Combine, and the newest is async/await. It’s important for iOS devs to know them all. Comparison here: ruclips.net/video/9fXI6o39jLQ/видео.htmlsi=34gCTbav25aw9gJC

    • @lowlydeveloper3693
      @lowlydeveloper3693 Месяц назад

      This is a good question! Learning Swift with knowledge of Dart, I am not liking this syntax at all in terms of readability. As Nick is saying here, I understand that devs need to be able to read "old" code when working in teams, but as a solo dev, I definitely prefer to use async/await (just like Dart). So much cleaner, and so much more readable. Thanks for the explanation Nick! 👍

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

    I’m not sure how many times I watched this video but I think finally I got it. Well I’ll let you know once I start typing code. What I want to do is start a function but as the function is running send out a status @State value to the view in real time. I’m hoping this method of escaping will do that? What do you think?

  • @m__link6499
    @m__link6499 3 года назад

    Hey Nick, in 5:17, why do you write let newData=downloadData() , then text=newData instead of writing directly text=downloadData() 🤔. Thank you

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

    I've been trying to understand this for 3 days now

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

    Can you please share the code,It will be of great help.

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

    Well my plan did not work. The code worked in that there were no errors but the @StateObject value would not display in the view in real time. I’m at a lost!

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

    I've enjoyed your other videos but found this a bit lacking in depth. If the compiler can already tell you need @escaping through the error message why do you need to explicitly state it. Are there cases when you don't need to state it? What is @escaping actually doing?

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

      @escaping is telling the compiler that this function we are passing it is going to “escape” the function it’s being called from. In other words, the function passed in can outlive the function it’s called within

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

    Not doing it for me, this one!
    Sorry Nick!

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

    Thank you Nick , You are magnificent 🤎

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

    ohh. it so complicated 🥲