Introductions to Closures in Swift

  Рет қаралды 12,564

Stewart Lynch

Stewart Lynch

Күн бұрын

Пікірлер: 103
@medicaldoctoronyoutube
@medicaldoctoronyoutube 3 жыл бұрын
Thanks a lot for your video. Perhaps the best I've seen on this topic. Watching your videos from Russia, Moscow.
@benyaminabediyan5451
@benyaminabediyan5451 4 ай бұрын
Usually I don't write any comments but thank you Stewart; you helped me understand this damn concept. Really appreciate your work. hope you would start making a full fledged course on Swift and SwiftUI.
@root_pegasus
@root_pegasus 6 ай бұрын
I've paid for the "best" content in Udemy and nobody explains like you It's amazing that content like this is free
@StewartLynch
@StewartLynch 6 ай бұрын
I am glad you are finding it useful
@pifeeder9027
@pifeeder9027 3 жыл бұрын
Best explanation on closures I have ever seen
@christophgeisel9708
@christophgeisel9708 Жыл бұрын
I have been struggling to understand Closures and tried all kinds of reading materials and tutorials to no avail. This tutorial was simply amazing and if it’s any further indication of the teaching style, why did I not find you sooner 😆
@StewartLynch
@StewartLynch Жыл бұрын
I guess I have to improve my advertising :).
@spacemeter3001
@spacemeter3001 3 жыл бұрын
This video is worth GOLD. Struggled to understand the syntax of closures and how they're used but now I understand it thanks to your examples!
@StewartLynch
@StewartLynch 3 жыл бұрын
Thanks. That is what I set out to do. Appreciate the feedback.
@sawjaixx711
@sawjaixx711 3 жыл бұрын
THANK YOU!!! Your detail explanation helped solve my confusion.
@StewartLynch
@StewartLynch 3 жыл бұрын
Great. Glad it could clarify for you.
@Landon_Hughes
@Landon_Hughes 3 жыл бұрын
Closures are definitely one of the more confusing topics in Swift; this video explains them perfectly!
@absar66
@absar66 Жыл бұрын
This is called quality tutorial with calm instructions...many thanks 👍
@eyupmert7338
@eyupmert7338 10 ай бұрын
Amazing. I really can't say anything else. I was struggling with closures, it's hard to understand because it's hard to explain I guess 😅 But you found a great way to explain the topic. Incrementing the level of knowledge slowly with different examples. And showing behind the scenes slowly. That's it! 👏
@StewartLynch
@StewartLynch 10 ай бұрын
Glad it helped!
@mhfs61
@mhfs61 3 жыл бұрын
As always, very educational Stewart. No voodoo, just calm and clear explanation. 👍🏼👍🏼👍🏼
@FRkiddo
@FRkiddo Жыл бұрын
this is great, your style of explaining is really good
@kal5211
@kal5211 Жыл бұрын
Excellent. Thank you.
@abhiireddy6
@abhiireddy6 3 жыл бұрын
one of the bestest lectures i have ever listened.. thank you very much
@toluojo6141
@toluojo6141 3 жыл бұрын
You are the best. Can't believe how much I've learned so far from you. Thanks a million
@StewartLynch
@StewartLynch 3 жыл бұрын
Happy to hear that!
@samuelpatrickhenness
@samuelpatrickhenness 3 жыл бұрын
Thanks Stewart, another really useful video. its great to finally understand how things I've been doing for a while actually work!
@StewartLynch
@StewartLynch 3 жыл бұрын
Glad it helped! That is exactly what I am trying to achieve with my videos. My rule now is to not use anything that I do not understand myself.
@joshuashires
@joshuashires 3 жыл бұрын
Epic once again Stewart. I have read the documentation over and over about closures and struggled to grasp the “Why” but comparing them to how we would usually write functions really really helped. A great follow on to this video would be expanding on the “Why?”. Your explanation using the VStack example was a big “Ohhhh i get it” moment but it would be good to see more examples of why should we use closures with real world examples. The thing I find hard is looking at a problem and implementing closures because doing it with functions in the traditional way just makes more sense and I cant see the advantage to using closures. However your completion handlers video might help with implementation of closures. Keep up the good work! Thank you for your contribution.
@davidspicer8053
@davidspicer8053 3 жыл бұрын
Certainly the absolute best video on closures i've ever seen!
@StewartLynch
@StewartLynch 3 жыл бұрын
Thanks for that David. Glad you liked it.
@cristhianleon2228
@cristhianleon2228 3 жыл бұрын
What a clear and detailed explanation, especially with the capturing values. Thanks!
@baylorjaxton5199
@baylorjaxton5199 3 жыл бұрын
sorry to be offtopic but does any of you know a tool to log back into an instagram account? I was stupid forgot my password. I would appreciate any help you can offer me!
@judsonbrendan657
@judsonbrendan657 3 жыл бұрын
@Baylor Jaxton instablaster =)
@baylorjaxton5199
@baylorjaxton5199 3 жыл бұрын
@Judson Brendan Thanks so much for your reply. I found the site thru google and Im trying it out atm. I see it takes quite some time so I will get back to you later when my account password hopefully is recovered.
@baylorjaxton5199
@baylorjaxton5199 3 жыл бұрын
@Judson Brendan it did the trick and I finally got access to my account again. Im so happy:D Thanks so much, you really help me out :D
@judsonbrendan657
@judsonbrendan657 3 жыл бұрын
@Baylor Jaxton no problem xD
@semilife
@semilife 3 жыл бұрын
Thanks Stewart un-voodooing the Voodoo. Clear simple, concise.
@StewartLynch
@StewartLynch 3 жыл бұрын
Glad you found it helpful
@headach09
@headach09 Жыл бұрын
Lots of cases comparing !! Much thanks :)
@jasurrajabov
@jasurrajabov 3 жыл бұрын
Tutorials are one of the best, with both high-quality video edit and the content itself very informative. Also love to see tutorials using closures with using weak, unowned. Thank you very much.
@AchrafTrabelsiMobileDeveloper
@AchrafTrabelsiMobileDeveloper 2 жыл бұрын
Thank your for this amazing video about closure, very helpful !
@edwarmartinez228
@edwarmartinez228 2 жыл бұрын
Thank you Stewart, you are Really a teacher
@jaaviondavis9790
@jaaviondavis9790 3 жыл бұрын
Thank you so much! I was struggling to figure out the meaning, the syntax, the use cases of closures in swift. After watching the video I'm able to logically think it out as a code and not stray away from the context. Please upload more videos because the way you explain concepts and your thought process is impeccable. I will definitely subscribe.
@StewartLynch
@StewartLynch 3 жыл бұрын
I am approaching 150 videos now so I will continue. Enjoy.
@jaaviondavis9790
@jaaviondavis9790 3 жыл бұрын
@@StewartLynch Do you have any videos explaining protocols and delegates?
@StewartLynch
@StewartLynch 3 жыл бұрын
I don’t think so. I seldom use them now with SwiftUI as there are alternate ways. I prefer to pass closures.
@marcaupont9145
@marcaupont9145 3 жыл бұрын
Great job Stewart! Very thorough explanations!
@StewartLynch
@StewartLynch 3 жыл бұрын
Thanks Marc. This means a great deal coming from you,.
@ribosome8085
@ribosome8085 2 жыл бұрын
Steward is awesome 👏 thank you so much!
@shadieossei4336
@shadieossei4336 3 жыл бұрын
Great job explaining! I'm beginning to understand closures a little bit.
@3luizcunha
@3luizcunha 3 жыл бұрын
Always incredible videos, thank you very much Stewart
@StewartLynch
@StewartLynch 3 жыл бұрын
Thanks
@rolandolahmusic
@rolandolahmusic 3 жыл бұрын
Fantastic explanation!
@leneil46
@leneil46 Жыл бұрын
Wow this video helped me out so much! Thank you.
@daniel_munoz_r
@daniel_munoz_r 3 жыл бұрын
Thank you very much for this video.
@Simon-ro8nh
@Simon-ro8nh 3 жыл бұрын
What a great video! This is super helpful! Thank you Stewart!
@DavidKoontz
@DavidKoontz 2 жыл бұрын
Thanks that was a great explanation.
@abdulbasir8740
@abdulbasir8740 3 жыл бұрын
Such an amazing tutorial, Thanks a Billion.
@StewartLynch
@StewartLynch 3 жыл бұрын
You're very welcome!
@Александра-ш8ж1б
@Александра-ш8ж1б 3 жыл бұрын
I admire you! Thank you for such a detailed and simple explanation.
@KimbrellBrad
@KimbrellBrad 3 жыл бұрын
That @escaping example really made me understand what is happening in these cases! Never really go it until now. Thanks Stewart! Oh, I have to ask...who does your cover art for these videos? They are really entertaining and have a lot of thought behind them! Bravo! BTW, I think it is you, your significant other, or a good friend. This much detail would likely be expensive!)
@StewartLynch
@StewartLynch 3 жыл бұрын
I use a free app called Bitmoji Brad. Available on the App Store. You design your own avatar and then it provides you with hundreds of scenes that you can pick from. Anyone can do it. Other KZbin content providers use it as well.
@shreesharao8308
@shreesharao8308 3 жыл бұрын
Best Explanation..It was helpful... Keep it up :)
@kasunjayasekara3052
@kasunjayasekara3052 3 жыл бұрын
Thank you very much finally I understand it correctly :)
@StewartLynch
@StewartLynch 3 жыл бұрын
Glad I could help
@ravisaini8034
@ravisaini8034 3 жыл бұрын
Thank you so much sir.
@lautarob
@lautarob 11 ай бұрын
Hello, enlighten videos! Thanks subscribed!!
@ScottGrunwald
@ScottGrunwald 3 жыл бұрын
Thanks for the great video
@oneCrispy
@oneCrispy Жыл бұрын
thank you.
@drmucahiderdogan
@drmucahiderdogan 3 жыл бұрын
Great video.
@Aightbruh02
@Aightbruh02 3 жыл бұрын
Please do a similar video about memory management and retain cycle
@vamsi3877
@vamsi3877 3 жыл бұрын
Wow superb 👏
@doesntmatter6827
@doesntmatter6827 3 жыл бұрын
Amazing!
@1sudrap
@1sudrap 3 жыл бұрын
Very nice and comprehensible video which really helped me to get a good grasp of this topic, but just a small remark: Why do you say "Declare variable" and actually declare a constant. You did it at least twice in this video. But anyway great job.
@StewartLynch
@StewartLynch 3 жыл бұрын
Yah, I make that mistake all the time and interchange variable and constant. I try to catch and correct those things, but as you can see, I am not always successful. I have a tendency like many others to use variables when constants will do just fine. I script my videos before I record the video and then add the audio later after recording. As I am building the video, I realize that a constant will be just fine and then forget to edit my script when I am recording the audio. I will try harder next time to catch these things.
@brandonwinston
@brandonwinston 3 жыл бұрын
How does it work that your “PublicFunctions” function takes a ()->Void but then we toss a bunch of different types of closures at it that are not ()->Void?
@StewartLynch
@StewartLynch 3 жыл бұрын
Perhaps this will clear it up. We can create a function that itself contains whatever code we want, including other functions. func example1() { func sayHello() { print("Hello") } sayHello() } Notice that example1() has no parameters and returns nothing so it is of type () -> Void We can then use that public "code" function to pass in example1 as our sampleCode because it meets the requirement for our closure. code(for: "Another Example", sampleCode: example1) Now, because sampeCode is a trailing closure, it could be written like this: code(for: "Another Example" { example1() } So instead of defining example1 as a function, we can simply pass in the body like this. code(for: "Another Example") { func sayHello() { print("Hello") } sayHello() } Does that help?
@brandonwinston
@brandonwinston 3 жыл бұрын
@@StewartLynch yes thank you very much!
@kenturnbull9679
@kenturnbull9679 3 жыл бұрын
This one??? I see Completion handlers as well. KT
@itchyminge
@itchyminge Жыл бұрын
Why do you call finallySayIt within the function, and then pass in a different function (closure) called reallySayIt? Could you not call finallySayIt within the sayHello function?
@StewartLynch
@StewartLynch Жыл бұрын
I am not sure I understand your question. Feel free to email me if you want to explore this further.
@Sokrates8
@Sokrates8 3 жыл бұрын
Strangely I can't download the Starter Files with the Chrome Browser; always have to switch to safari.
@StewartLynch
@StewartLynch 3 жыл бұрын
Sounds like a security issue. It is a Zip file so that could be your issue.
@kenturnbull9679
@kenturnbull9679 3 жыл бұрын
@@StewartLynch I regularly use Chrome, Canary, and Firefox Dev. I can download the starter files in ALL of them as well as unzipping them. In fact, I just checked all of them before I commented. In addition to the Closure info, I really enjoyed seeing what things can be done with Playground... but my spelling is starting to suffer :-)
@nickapeed
@nickapeed Жыл бұрын
Great video here and your other work! I'm a new subscriber, thanks!! Question for anyone that can help me at 10:08 func sayHello(to name: String, finallySayIt: (String) -> ()) { what is the purpose of the "to" here?
@StewartLynch
@StewartLynch Жыл бұрын
It is simply there to make the function more readable at the call site. sayHello to “xxxxxx” instead of sayHello “xxxxxx”
@mcquinmadtha
@mcquinmadtha Жыл бұрын
"to" is the external parameter name, whereas "name" is the internal parameter name. So when passing a parameter, instead of saying sayHello name: "Sam", it would look like sayHello to "Sam", much more readable
@mx.stoneheart
@mx.stoneheart 3 жыл бұрын
@14:00 calling me TF out
@StewartLynch
@StewartLynch 3 жыл бұрын
I think we have all been there.
@richoffks
@richoffks 3 жыл бұрын
bruh, I wasted two hours finding out this code doesnt even work smh
@StewartLynch
@StewartLynch 3 жыл бұрын
Pardon me? What are you referring to? It would help if you could be more specific, because the code does indeed work in this video.
@richoffks
@richoffks 3 жыл бұрын
@@StewartLynch when I create the exact same functions as the one in the video, an error pops up because of the incorrect parameter name
@StewartLynch
@StewartLynch 3 жыл бұрын
DM me on Twitter @StewartLynch and share your code with me so I can see what you are doing wrong.
@StewartLynch
@StewartLynch 3 жыл бұрын
I also just downloaded the completed playground from the link provided and all of the code works fine, even in Xcode 13 beta so you must be doing something wrong in your implementation. I am more than happy to check your code.
Introduction to Generics in Swift
24:13
Stewart Lynch
Рет қаралды 6 М.
Completion Handlers
17:06
Stewart Lynch
Рет қаралды 12 М.
бабл ти гель для душа // Eva mash
01:00
EVA mash
Рет қаралды 8 МЛН
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 132 МЛН
У вас там какие таланты ?😂
00:19
Карина Хафизова
Рет қаралды 26 МЛН
Swift Closures Explained - The ONLY video you'll ever need!
17:33
How to create and use closures - Swift for Complete Beginners
18:39
map, compactMap flatMap
17:06
Stewart Lynch
Рет қаралды 8 М.
Introduction to enums in Swift
15:22
Stewart Lynch
Рет қаралды 5 М.
Throw, Try, Try? Try! Catch
13:38
Stewart Lynch
Рет қаралды 4 М.
Swift for Beginners Part 13 - Closures
12:42
iOS Academy
Рет қаралды 33 М.
Swift Closures Explained
14:23
Sean Allen
Рет қаралды 67 М.
Threads and Grand Central Dispatch in Swift
22:14
Stewart Lynch
Рет қаралды 22 М.
бабл ти гель для душа // Eva mash
01:00
EVA mash
Рет қаралды 8 МЛН