Learn more with my iOS Development courses - seanallen.teachable.com
@Хумо-х7з Жыл бұрын
Where are you calling presentProductSelectionVC?
@srebulla10 ай бұрын
I've had to rewatch this video a couple of times, but now it has "clicked". Thank you for explaining this in a way so many tutorials did not!
@seanallen9 ай бұрын
Glad it finally clicked for ya!
@djryanashton Жыл бұрын
5:50 "I'm not actually going to call from within the ViewController, I'm gonna call it from somewhere else". This was a key moment for me to understand conformance. I have previously struggled to understand delegate methods. This helped. Thanks.
@seanallen Жыл бұрын
Glad it was helpful, Ryan. Delegates were tricky and took me a bit to fully grasp. I tried to use all my "light bulb moments" in this video.
@davidruvinskiy63472 жыл бұрын
Your original delegates and protocols video was one of the videos that made me discover your channel. Thanks for recreating it. Keep up the good work, Sean!
@seanallen2 жыл бұрын
No problem David. I appreciate the long-time support!
@tzuuyaolee9402 Жыл бұрын
the "job description" concept is on point. thanks.
@seanallen Жыл бұрын
Glad it helped!
@YianniYiannakidi2 жыл бұрын
Dear Sean. I have bought your book, and I was inspired from your story. I want you to know that you have fans from the other side of the world 🇬🇷 Every video you make is so helpful. Thank you for recreating in this version.
@numb9802 жыл бұрын
should have bought Matt Neuburg's instead
@seanallen2 жыл бұрын
Happy to help, Ioannis 😀
@mediterrenean Жыл бұрын
Clear and concise, that is exactly what beginners need. Huge thumb-up! You don't skip over the details required to understand new concepts.
@marcx38272 жыл бұрын
By far! The best explanation of this topic. Especially the hint that this functinons are getting fired automatically in a lot of framworks. Great job Sean!
@seanallen2 жыл бұрын
That was the key piece of the puzzle for me. Once I understood that, delegates made sense to me.
@mfgucluer4 ай бұрын
The best protocol delegate video in youtube platform. Thanks a lot...
@seanallen4 ай бұрын
Thanks! Happy to help.
@numb9802 жыл бұрын
To prevent strong reference cycles, delegates are declared as weak references (Swift Doc) In your case this kinda works only because you don't hold a reference to destination. But in real world, in 99% of situations, the owner holds a reference to its delegate, and a delegate has its owner. Hence why you should always use weak, can't go wrong
@seanallen2 жыл бұрын
Many use cases require a weak reference and I should have mentioned that. That is a fair point and I accept that criticism. 99% is a bit much tho. The way I demonstrated delegates is how I write them the vast majority of the time when communicating between two views. I would also argue that a developer understanding when and where to use "weak" is the better than adding weak to everything just to be safe.
@ebubeawachie Жыл бұрын
@@seanallen Besides using weak could lead to issues when the delegate methods are being called from within an escaping closure right? Because the closure could be deallocated? Or am I off my rocker?
@philipps19 Жыл бұрын
@@seanallen Just accept that you've been wrong and go forward. You don't need to write 'weak' everywhere, but as @numb5206 said, delegate and escaping closures situations are 99% must have.
@nileshjdarji Жыл бұрын
Out of all videos that you have made on delegates and protocols, I like this one the most. Also thanks for teaching how to do the bottom sheet as well. Thank you.
@axemanaxeman Жыл бұрын
Big fan of your original video on Delegate as I still refer it to this day. The new video on delegate is an added bonus to my swift learning path. Thank you!
@joshuajean468310 ай бұрын
Thanks for spending time explaining analogies and providing source code!
@seanallen10 ай бұрын
I appreciate the generosity! Glad you found the video helpful :)
@ZulquarnainShah-u1u8 ай бұрын
I don't really like how much code we have to write for a simple communication between views. How can we achieve this using combine framework?
@Maziyarlayeghkar Жыл бұрын
Finally a good video about delegate pattern. Thank you Sean!
@seanallen Жыл бұрын
Glad you enjoyed it, Maz!
@joshuajean468310 ай бұрын
Thank you, now to create my own example to cement it. Thank you for providing source code and using time to explain analogies vs setting up UI.
@seanallen10 ай бұрын
Glad it was helpful!
@EduardoEscaleira Жыл бұрын
Nicely done! In the first 7 seconds of your video I already knew what a Protocol is capable of. Congrats!
@dan_pal8 ай бұрын
Amazing explanation, the best Swift KZbinr imo
@seanallen8 ай бұрын
I appreciate that :)
@kurdi-19198 ай бұрын
Amazing explanation! Really appreciate your videos.
@seanallen8 ай бұрын
Glad it was helpful!
@mariojackson8022 жыл бұрын
Thank you for the analogy, Sean. I had a bit of a hard time understanding them and I just saw that you created a video about it at the right time (for me). I also bought multiple of your courses and I can only recommend them. Do you ever plan on creating an in depth course for UIKit for developers completely new to iOS development?
@seanallen2 жыл бұрын
Glad this was helpful, Mario and I hope you enjoy the courses! I plan on making a job preparation course later this year (for both SwiftUI and UIKit). It will replace the GitHub Followers course which is starting to get a little old.
@samr.46922 жыл бұрын
Great, short, and effective tutorial. Thank you!
@seanallen2 жыл бұрын
Happy to help, Sam!
@denizc1019 Жыл бұрын
Concise and clear thank you, I know it is not this tutorial's subject but you need weak delegate otherwise it will cause retain cycle. Cheers!
@jaymee05232 жыл бұрын
The delegate should be declared weak 😆😆😆
@seanallen2 жыл бұрын
Should it in this case? 🤔. The project source code is in the description. Open up the memory graph debugger and take a look.
@dmytronice1337 Жыл бұрын
Thank you so much for this video, right now I am reading your book and it very inspiring!
@seanallen Жыл бұрын
Happy to help! Hope you enjoy the book 😀
@t0mb0lt0n Жыл бұрын
Thanks a lot Sean for simple explanation and perfect example, this example really helped me
@Stu495838 ай бұрын
The intern decided to hire himself 😂 I wish it worked like this in real life too 😂
@contrerasmaxiflyАй бұрын
I think I finally understood!!!Thanks!!!😂
@seanallenАй бұрын
Happy to help!
@gusgonnella7706 Жыл бұрын
Very helpful, thank you for making this video. As a swift novice, good videos like this are monumental in helping me understand
@renagurbanovasenglish7 ай бұрын
Thank you, that was the greatest explanation ever😍😍😍
@seanallen7 ай бұрын
Glad it was helpful!
@wasimsafdarhumma55158 ай бұрын
Nice "Repetition is the keyword to learn this stuff"
@seanallen8 ай бұрын
Exactly
@loO5r Жыл бұрын
That is a very good explanation for the the Delegate pattern! But for me the responsibility still feels twisted. I would pass a callback onSelected(name: String, imageName: String) into the ProductSelectionVC. ProductSelectionVC's responsibility would then only be to select and the ViewController has full control of what to do with this selection (in this case showing it to the user). In this way imho the code is also easier to understand because when the developer reads through the ViewController's code, he knows exactly what happens with the selection. Am I thinking wrong, do I miss something in my approach? Thx!
@leunamvon25657 ай бұрын
Very well explained, Sean.
@GreenDevBabe2 жыл бұрын
Thank you very much! I knew how to do it but didn’t know how to explain on interview
@seanallen Жыл бұрын
Glad it was helpful!
@Juliapak Жыл бұрын
hello! I am trying to build an app with a reward card (like starbucks). Have you ever built something like this? If so is there an api/platform that lets you do this? like stripe etc???
@haydenwadsworth70642 жыл бұрын
Love your videos! Always learning from you :) keep it up!
@seanallen2 жыл бұрын
Thanks Hayden!
@mashfikurrahman11152 жыл бұрын
Really it's gonna be such a cool feature for iOS, Thanks for the excellent explanation with the perfect example! :)D
@seanallen2 жыл бұрын
Glad you liked it, Mashfikur!
@marinaalecriim2 жыл бұрын
Best tutorials! ✨
@seanallen2 жыл бұрын
Thanks Marina!
@j.p.bikes22 Жыл бұрын
Hey Sean, great video, I am building an App in Storyboard and I put the destination.delegate = self into the button function which brings up the secound Viewcontroller. Running it showed that the protocol function never actually runs, I believe because its never actually send over. Could you help me pls?
@stqrsky Жыл бұрын
very good explanation, i am struggling but am always motivated by you. thanks!
@seanallen Жыл бұрын
You got this, Starsky!
@ialtoobi Жыл бұрын
Thanks Sean for sharing knowledge ;)
@seanallen Жыл бұрын
Happy to help, Muhammad!
@josejaimefelixgarciagarcia8884 Жыл бұрын
4:43, The way I think of this part is that the boss is setting up a job posting, it will create a spot (which is the var) for a person who would want to work on it (someone who sets himself as the delegate) 7:27
@karlostj4683 Жыл бұрын
Another important idea associated with delegates and protocols: There is an implicit assumption that the "delegate" object might change. In this case, the delegate is a ViewController, but in the same app at some later point in time or some alternate context, the delegate might be some other kind of object. However, this presumes that this behavior+context is going to come up multiple times. Because if it only occurs once, setting up the protocol and managing the delegate might be a waste of time. For instance, for every UITableView, there's usually one and only one object that's going to be that table view's data source and/or table view delegate.
@clearcut36742 жыл бұрын
Thank you very much, Sean, for your hard work. Your videos are always the best! Are you planning to release joint content with Paul Hudson?
@seanallen2 жыл бұрын
Glad you enjoyed it! Paul and I used to work together on a podcast, but there are no plans for joint content at the moment. There's no ill will or anything. We're just both doing our own things.
@ordozgoite10 ай бұрын
Thank you so much!
@seanallen10 ай бұрын
Happy to help!
@qaziaydan1143 Жыл бұрын
You are the best ❤
@seanallen Жыл бұрын
I appreciate the kind words :)
@pashaotverchenko51092 жыл бұрын
Thank you for sharing that!
@seanallen2 жыл бұрын
Happy to help, Pasha!
@elaf709210 ай бұрын
very helpful
@seanallen10 ай бұрын
Happy to help!
@Maziyarlayeghkar Жыл бұрын
Please also make one for Combine.
@joaquimmenezes7396 Жыл бұрын
Thanks sean !!
@pstlvictoras16 күн бұрын
thank you!
@francoramiro72 жыл бұрын
Super clear!🎉
@seanallen2 жыл бұрын
Thanks Franco!
@superfortekiaiАй бұрын
Awesome!
@MainActor Жыл бұрын
For me, where this Boss and Intern analogy falls apart when I was just starting about 4-5 years ago was that the intern is creating or instantiating the boss object 😂 which is unheard of and slightly misleading at that time.
@iosdev012 жыл бұрын
also teach how to work with table view through the protocol
@seanallen Жыл бұрын
I have a TableView video on my channel
@_tahabebek2 жыл бұрын
We would like to see the same tutorial with SwiftUI. Pretty sure it will be much cleaner and simpler!
@seanallen2 жыл бұрын
The delegate and protocol communication pattern isn't really a thing in SwiftUI. They way to communicate between views is SwiftUI is much different.
@_tahabebek2 жыл бұрын
@@seanallen true, usually the pattern is swiftui views call functions on their viewmodels to handle user actions.
@JasonMitchellAZ2 жыл бұрын
Great update to the original. You didn't want us to choose the dark side, though? (I think that's what you did last time, right?)
@JasonMitchellAZ2 жыл бұрын
Also, I see you're not aligning your "=" anymore... when did you come over to the dark side? 😆
@seanallen2 жыл бұрын
It got too tedious for my liking, lol
@victorriurean2 жыл бұрын
nice
@JakobKoblinsky3 ай бұрын
Anyone know why Apple devs call this a delegate pattern when the "this" context isn't the caller's?
@ashdeng43832 жыл бұрын
weak var delegate.... otherwise retain cycle (aka. memory leak)
@seanallen2 жыл бұрын
Should it in this case? 🤔. The project source code is in the description. Open up the memory graph debugger and take a look.
@krisright73042 жыл бұрын
funny, but I just went through the first protocol&delegate tutorial. And I'm wondering why you made the same video?
@seanallen2 жыл бұрын
Because the other video is almost 6 years old and I talk REALLY fast in it (I get a lot of complaints about that in the comments). Many people watch that video as a resource for interviews and I felt that I could make a better, more modern version of it. I'm going to be redoing my entire "Interview Tips" playlist with modern versions.
@leifashley2 жыл бұрын
This doesn't look like swiftui... :) 👍 - good Vid though, there's a lot of UIKit code out in the corporate wild.
@seanallen2 жыл бұрын
Lol, I'm mixing in some UIKit focused content. I feel all the KZbinrs have gone all in on SwiftUI, that there is a vacancy for UIKit content.
@leifashley2 жыл бұрын
@@seanallen That's a good idea. I love swiftui, but we are locked down to UIKit and programmatic at that... so work wise, this is more beneficial to me.
@andriy1131 Жыл бұрын
No storyboard used. I don't understand
@Bertie211 Жыл бұрын
I’m lost!!!
@OnionKnight5417 ай бұрын
respectfully, if you're looking for a way to teach this concept, i don't think the intern / boss metaphor is the best option.