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

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

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

  • @j1nMatt
    @j1nMatt 3 ปีที่แล้ว +25

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

  • @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 😎

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

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

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

      Happy to hear that Essa! Thanks for watching.

    • @dariusdumitrescu
      @dariusdumitrescu 2 ปีที่แล้ว +1

      Same journey for me. Thanks Nick!

  • @ashishprajapati825
    @ashishprajapati825 2 ปีที่แล้ว +1

    Best explanation about escaping 🤩👏

  • @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!

  • @elemento_artz
    @elemento_artz ปีที่แล้ว

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

  • @BSharing09
    @BSharing09 2 ปีที่แล้ว +1

    Well explained. Thank you so much.

  • @lyndicastrejon4048
    @lyndicastrejon4048 ปีที่แล้ว

    Wow, very concise and explained extremely clear

  • @nolanmorrow6028
    @nolanmorrow6028 2 ปีที่แล้ว +2

    Your lessons are excellent!

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

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

  • @sheetalpahadi
    @sheetalpahadi หลายเดือนก่อน

    Very very informative

  • @bruhmoment3731
    @bruhmoment3731 2 ปีที่แล้ว

    Another very well explained video!

  • @Collins01
    @Collins01 2 ปีที่แล้ว

    Well explained. ✅

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

    super video .. very welll explained

  • @MrShumylo
    @MrShumylo 2 ปีที่แล้ว

    Quite a clear explanation. Thanks a lot!

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

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

  • @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?

  • @ЕнСобЛи
    @ЕнСобЛи 3 ปีที่แล้ว +1

    you are the best! Thank you so much

  • @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!

  • @williamwildsmith5162
    @williamwildsmith5162 2 ปีที่แล้ว +1

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

  • @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 :)

  • @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?

  • @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: th-cam.com/video/9fXI6o39jLQ/w-d-xo.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! 👍

  • @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

  • @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.

  • @abhiireddy6
    @abhiireddy6 ปีที่แล้ว

    Crystal clear

  • @alextoma402
    @alextoma402 ปีที่แล้ว

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

  • @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

  • @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!

  • @deveshpandey2710
    @deveshpandey2710 ปีที่แล้ว

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

  • @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 🥲