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

Published 2021-04-20
In this video we will learn why we need @escaping closures and how to implement them! While many courses use these closures, very few explain why they are required and it often becomes a confusing topic for new developers. We use @escaping closures to deal with returning from functions when using asynchronous code. This is code that does NOT execute immediately, but rather at a future point in time. This becomes extremely important when we need to download data from the internet!

Next video:    • Codable, Decodable, and Encodable in ...  
Last video:    • How to use Typealias in Swift | Conti...  

🤙 WELCOME BACK 🤙

WEBSITE: www.swiftful-thinking.com/

DISCORD: discord.gg/tSzJGx9RwE

GITHUB: github.com/SwiftfulThinking/

SAY THANKS: www.buymeacoffee.com/nicksarno

All Comments (21)
  • @j1nMatt
    Your tutorials are very practical compared to others, specially for people coming from other programming languages
  • @EssaAlshammri
    I’ve seen like 5 videos about escaping but this one sank in easily 👍 thanks
  • @bobearl99
    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!
  • @MrShumylo
    Quite a clear explanation. Thanks a lot!
  • @elemento_arts
    lol.. love how you called "we went from this ugliness here" hahaha 🤣. Amazing tutorial as always Nick, Thanks!!
  • @paulmax9155
    ... after 14 minutes we saw the first example of code with escaping 🥳
  • 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?
  • Had to run through this a few times. Struggle with this - my bad - not bright enough!
  • @pitmanra
    Well presented, but it still makes my head spin.