Swift Closures Explained

preview_player
Показать описание

I explain what confused me most when learning closures. What do the parenthesis mean? What are the $ in closures (shorthand syntax)? What does @escaping mean? What is Trailing Closure Syntax? This Swift tutorial was created in Xcode 14.

Automatic Reference Counting - Memory Leaks & Retain Cycles:

iOS Developer Courses

Twitter:

Book and learning recommendations that help out the channel if you decide to purchase (Affiliate Links):

Paul Hudson's Hacking With Swift:

Donny Wals - Combine:

Mark Moeyken’s SwiftUI Books:

Ray Wenderlich Books:

#swift #softwaredeveloper #iosdeveloper

Timestamps:
0:00 - These confused me
0:22 - Build a closure and pass it around
3:11 - Closure Types
5:17 - Shorthand syntax - $0, $1
5:30 - Trailing Closure Syntax Intro & Shorthand Syntax
9:34 - SwiftUI - Trailing Closure Syntax
12:09 - @escaping - What does it mean?
Рекомендации по теме
Комментарии
Автор

I’m going to be honest with you, this was a G-R-E-A-T explanation. I’ve read so many Medium posts and Stack Overflow answers where people either try to sound too smart or they just don’t realize that they’re not speaking in layman’s terms (they’re speaking to other people who don’t need it explained). This took a very simple approach to something complicated and made it simple. FANTASTIC explanation!!! You do a great job of keeping things simple! Seriously. And I like your graphics!

lancesamaria
Автор

That 15 minutes just saved me so much time developing my first native macOS app.

Thank you!!

Best Swift tutorials on YouTube.

evan_ry
Автор

(well)->(explained) {Thanks a lot for great video}

vadirajhippargi
Автор

Was confused AF going through swift tour, but this video really cleared everything up.. thanks!!

jadethompson
Автор

It's weird, but when you explained how VStacks use trailing closure syntax, my understanding of swiftUI drastically improved. I am the type of person that not only wants to memorize the syntax, but also understand why it is written like that. Thanks!

miguel.sanchez
Автор

Hi Sean! I've been working on my programing career for about 2 months now. I'm doing the 100 days of swift with Paul Hudson. Even tho this is all still a bit blurry i do appreciate your content since its starting to clear a bit of the fog that i had. Just wanted to stop by and say thanks! You'll probably see me around a bit more ✌

Adrian.katzenstein
Автор

WOW! The most Clear and concise explanation I've seen on closures in 6years of developing.

ingongoyama
Автор

This video came at Great time, currently figuring out this developing game.🙏🏾

MrMainstay_
Автор

I've just started delving into the mystery that is closures. Your video helped both for what they are and, especially, why I will need to know them. Thanks!

allenwaddell
Автор

Thanks, that cleared up some things I’ve been putting off for a long time 👍🏻

david-holmes
Автор

Before I start this video, I started searching for videos on closures, while actively using “100 days of SwiftUI” lesson plan, but during the first couple lessons involving closures, I could not get out of my head the question “If functions do everything closures do, why then do closures even exist?” So hopefully I get that answer from this video, because this thought it slowing down my ability to progress in learning swift.

jonathanmartin
Автор

I absolutely loved the Swift Closures Explained video by Sean Allen. As someone who has struggled to understand closures, this video was a godsend. Sean does an amazing job of breaking down the confusing aspects of closures, like what the parenthesis mean and the shorthand syntax. He explains everything in a clear and concise manner, making it easy for even a beginner like myself to follow along.

I also appreciate the fact that Sean provides a promo code for Squarespace at the beginning of the video. It’s always great to get a discount when you’re starting a new website or domain.

Overall, I highly recommend this video to anyone who is struggling to understand closures, or anyone who wants to brush up on their Swift knowledge. Thank you, Sean, for creating such an informative and helpful video.

王登科-uc
Автор

Thank you so much for clearly explaining the $0 and $1 in closures. I have read and studied it so many times but now I just got it in 1 minute.

Thank you!

JeradAcosta
Автор

I am currently trying to learn Swift. And with every bit I code and video I watch I learn a 1% crumb of that language. But with the trailing closures explained it felt like an iceberg of 10% crashed into the water. Thank you.
I think, maybe Swift is so hard to learn, because in all tutorials you learn the shortcut syntax first and never get explained why this actually works. But it would be better to understand the full syntax and all the principals first and then teach the shortcuts.

sagmalrasmus
Автор

Extremely useful video. I came here for closures and learnt so many things I was confused ab all in one go thanks

pranavsubash
Автор

Finally my Javascript knowledge helps me out. I picked these up quickly.

jasonmountain
Автор

my issue with this video is it isn’t a discussion of closures in swift but a discussion of a syntactic sugar for function pointers.

unless i missed something, there wasn’t any point where you “closed over” or captured the environment when creating the closure, which is an essential part of closures. i assume you can also do this in swift closures but it wasn’t shown here

michaelthompson
Автор

Simple, nice and clear. Thanks for the video, Sean!

xmnihaze
Автор

best teacher i found about swift fundamentals

danielniels
Автор

Not a swift dev but some good information here that if you already know this it makes it connect from a different perspective. Great video

dixztube