Swift Delegate Protocol Pattern Tutorial - iOS Communication Patterns Part 1

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

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

  • @seanallen
    @seanallen  4 ปีที่แล้ว +7

    Watch Next - iOS Take Home Project - Job Interview Practice - Free Preview - th-cam.com/video/MSIe2y6Fee8/w-d-xo.html

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

      Hey Sean, I bought your iOS Dev course from your site and man I really wish I would’ve bought it sooner. I am a firm believer in the pay to play mentality and your course is just one more reason for that. I’ve just gone through the first five videos and you are very thorough, clear, and straight to the point giving the student everything they will need. I also like that the whole course is done programmatically without a storyboard. I honestly cannot say enough great things about what I’ve experienced so far.

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

      Thanks for the video, Sean! There is a minor issue with this line:
      var selectionDelegate: SideSelectionDelegate!
      Should be:
      weak var selectionDelegate: SideSelectionDelegate?
      There is no guarantee selectionDelegate will always be non-nil inside SelectionScreen class (unless it's a private property initialized based on a SideSelectionDelegate argument passed in a custom init(delegate: SideSelectionDelegate) {...} method).
      There are some exceptions when we must indeed use strong delegate properties, but in most cases we should use weak var delegate: SomeDelegate?

  • @ericamillado
    @ericamillado 7 ปีที่แล้ว +90

    The "intern" and "boss" analogy is so helpful, keep these videos coming!

    • @seanallen
      @seanallen  7 ปีที่แล้ว +3

      Glad you enjoyed it, Erica! I've always been pretty good at coming up with analogies to explain things... it's a fun way to teach.

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

      this is the first analogy for protocols/delegates that finally made me understand the concept. Thank you Mr. Allen.

    • @mryup6100
      @mryup6100 6 ปีที่แล้ว

      agree

  • @lamdbich
    @lamdbich 7 ปีที่แล้ว +7

    Finally someone who values my time so that I don't have to speed up the videos. Keep it up.

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

    i have watched all youtube videos on this topic on youtube. Most of them you fall asleep, or you have some guy trying to give sense to his thoughts. 99,99 % of the times are just pure confusion. Here Sean in 13 minutes goes so straight and clear to the point that even you are a total beginner you will understand it. Impressive. He speaks fast, but i have noticed that you need to keep this peace and speed of words not to get too lost in thoughts. Amazing job man. thanks.

  • @thomasdermaris4984
    @thomasdermaris4984 7 ปีที่แล้ว +101

    You have to declare your delegate var as weak to avoid reference cycles. This is one common question to interviews too..

    • @seanallen
      @seanallen  7 ปีที่แล้ว +106

      Hey Thomas, thanks for the feedback! I appreciate you guys keeping me honest. Anytime you put your code out there for the world to see, there's bound to be some missteps. To your point, you are correct if you declare your protocol as a class protocol, like `protocol SideSelectionDelegate: class', then you need to declare the delegate variable as 'weak' to avoid retain cycles. However, if don't declare your protocol as 'class' you're allowing your protocol to be adopted by structs, which are value types, and therefore don't really work with reference counting. This blog post provides a good explanation: useyourloaf.com/blog/quick-guide-to-swift-delegates/ . It's a clarification I neglected point out in my video. Thanks for bringing it up!

    • @thomasdermaris4984
      @thomasdermaris4984 7 ปีที่แล้ว +19

      Thanks for your answer Sean. To tell you the truth I wasn't aware of that..

    • @anupdsouza
      @anupdsouza 7 ปีที่แล้ว +7

      I had the exact same question when I began watching this video, glad I scrolled through the comments to find your reply Sean :)

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

      My first thought (I need to test it, will do it tonight) about this is that we are dealing with class instances and that's why I think there are memory leaks.

    • @wilsonbalderrama
      @wilsonbalderrama 7 ปีที่แล้ว +3

      OK I tested and I didn't find a strong reference cycle I believe that's because BaseScreen instance doesn't have a property that's referring to the SelectionScreen instance.

  • @AmitThakur-eg8kb
    @AmitThakur-eg8kb 3 ปีที่แล้ว +1

    one of the best iOS teacher on this planet. Good job Sean.

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

      Thanks for the kind words, Amit.

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

    Oh my goodness!!! This is the absolute best explanation of Delegates and protocol I have seen on the internet. Thanks so much Seal Allen. You be doing so much for us Swift noobs.

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

      Glad it was helpful, Mark!

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

      @@seanallen Sean, I’m having this issue of lack of confidence. I just started this journey some months ago band I’m switching from a career in medicine (I’m a Veterinary Doctor with an MSc in Veterinary Physiology but I’ve always loved technology).
      Sometimes it feels like I can’t just cut it. I’ve always been good academically graduating best in high school and college but coding is just a different ball game.
      I’ve always been able to understand things really really quickly but some things here just take a while to grasp.
      Is this normal for everyone?
      Are there any insights you can share for dealing with this?
      Sorry for the long read.

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

      Yes, this is normal. Coding is hard to learn at first, but just like any skill, the more you do it the more comfortable you get. I don't have any secret tip or anything. It's all about putting in the time and repetitions (just like any other skill). Then one day, things just start clicking.

  • @snebold
    @snebold 7 ปีที่แล้ว +4

    Hey, I love your tutorials! I think the speed is fine, but I especially appreciate the fact that you don't waste time launching Xcode and setting up the UI like so many other tutorials out there. You just get to the meat of the matter. Thanks!

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

      +Bill Snebold Thanks, Bill. I hear ya on that. I remember learning myself, and I always hated all the setup on EVERY video. As you've seen, i just do a quick review of my starter project, then on to he good stuff.

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

    Thank you, thank you, thank you... It's amazing how great your analogies are. It really helped me understand the flow of data and how everything works. I was having a moment a few days ago thinking "Maybe Software Engineering isn't for me. I don't understand this stuff and I can't do it. I should honestly give up." Its great to see that there's people out there like you that can articulate in non-technical terms to make understanding this stuff that much easier. Thanks again, you've earned one more subscriber!

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

    I spent the entire afternoon (and now night) tackling the problem of understanding delegates and their application. I've read article after article, downloaded and attempted to analyze projects provided by others, and read official documentation, but everything I've read and seen thus far seems to attempt to explain this concept to people who already understand this concept. Your video here actually explains the concept and relationships very well to someone like myself who is trying to get into coding.

    • @seanallen
      @seanallen  6 ปีที่แล้ว

      Happy to hear you found it helpful, M 👍

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

    I have been struggling with this for about two months now and you just made it so clear for me and I now understand it !! Thank you so much, you sir are a gent and a scholar !!

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      That's awesome to hear, Neil. Happy to help!

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

    I was using a static variable to pass data back and forth yesterday. I knew there had to be a better way, and after watching this video, I immediately went back to my project and changed it to a delegate-protocol pattern. The code is so much cleaner. Thank you so much Sean!

    • @seanallen
      @seanallen  4 ปีที่แล้ว

      Happy to clear that up, Ryan!

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

      Why is this a better way than passing a variable? I just don't understand... it doesn't seem straight forward, like "beating around the bush." I just don't get, WHY use delegates? Isn't there a simpler way?

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

    Sean you are unfolding the most difficult topics of iOS development with so much ease , after your videos everything makes more sense to me .. Thanks Buddy

    • @seanallen
      @seanallen  6 ปีที่แล้ว

      Glad you found it useful, Hanzula. I've got a lot more videos 😀

  • @lilyshevchenko7048
    @lilyshevchenko7048 7 ปีที่แล้ว +3

    You, Sir, are my hero! I am going through a coding bootcamp and our platform laid out info about protocols and delegates in such dry, confusing manner that I was struggling to understand what goes where until I saw your demo. In less than 10 minutes, everything snapped into place for me! Love the easy to understand and engaging example and love boss/intern analogy. Thank you for sharing your know-how.

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

      Happy to hear it helped you, Lily. I struggled with Delegates/Protocols for the first 6 months of my career, so I know how ya feel!

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

    I love your pacing. Straight to the point. And fast. Every time. Well done.

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

    One of the best iOS instructor! This tutorial helped me understand after countless hours understanding protocols and delegates!

    • @seanallen
      @seanallen  6 ปีที่แล้ว

      I appreciate the kind words, Dorian 🙌

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

    Clearest explanation of delegates in Swift I’ve ever found. Thanks Sean!

    • @seanallen
      @seanallen  4 ปีที่แล้ว

      Thanks! Glad you enjoyed it 😀

  • @mashfique
    @mashfique 7 ปีที่แล้ว +7

    This whole video was a "Aha" moment for me! Your videos are really good for reviewing concepts! Please keep uploading them :)

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      +Mashfique Anwar Thanks! More on the way!

  • @timharris72
    @timharris72 7 ปีที่แล้ว +3

    This is the best explanation I have seen so far of what delegates do. I do Qt programming (Python) and use delegates all the time for table views but it was always difficult for me to explain the Swift syntax to other people or understand the Swift syntax using delegates as it is a little bit different although the concept is the same. Thanks for the help.

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Glad to hear the video helped out, Tim!

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

    Thanks Sean, This is the best explanation of delegates by far. The Boss/Intern analogy is exactly what I needed to fully understand the concept. Great Stuff!

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Thanks Mauricio! Glad it helped. Appreciate you sharing via tweet as well.

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

    One of the best Delegates/Protocol tutorials I've seen. Thanks

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Much appreciated Bahe! Happy to hear the video helped!

  • @infinite5837
    @infinite5837 5 ปีที่แล้ว +4

    Great video!
    I'm currently building an application and this has made my life way easier.
    I was using notifications and observers. However, I started to notice that my code was getting messy.
    So I took the time to learn how protocols work and restructured my application.
    Great decision and good learning experience.
    Thank you!

    • @seanallen
      @seanallen  5 ปีที่แล้ว

      Happy to hear you found the video helpful, Sergio 😀

  • @stomachcontentz
    @stomachcontentz 6 ปีที่แล้ว +3

    Sean - love your stuff. It's great when you find someone who thinks in a similar way to you which makes the information transfer fast and effective. Maximum respect so much for taking your time to make these videos.

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

      Thanks for the kind words, Christian! Motivates me to keep going!

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

    One day i asked god to teach me iOS and he had sent you... Stay blessed @Sean Allen

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Thanks Lalitha!

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

    The best explanation I have seen so far. Great content Sean!

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

      Thanks for the kind words, Arnav 😀

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

    Short, simple and precise. This is the best tutorial on delegate protocol communication pattern I've found as a beginner. Bonus points for referencing Star Wars. Thanks man.

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

    Thank you so much! I could not find any helpful videos explaining protocols. Everyone elses videos weren't clear on how to use them in different situations, your video really helped me understand how to use them in all types of situations.

    • @seanallen
      @seanallen  6 ปีที่แล้ว

      Happy to hear it helped, Steve!

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

    Enjoy watching your videos. They're presented in a clear, logical way that makes it easy for me to understand. Thank you!

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Glad you enjoy them, Phontaine!

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

    Man I still sometimes don't get my head to wrap around delegates and protocols concept. But luckily I have this video of yours bookmarked so I always go back to watch it again to make myself clear. Awesome boss and internal anology. Thank you.

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

    I’ve watched a video about delegates/protocols every 3 months for the past 2 years and have always tuned out with glazed eyes about halfway through and walked away more confused than when I started. It was always difficult for me to envision the demo use case - but this time, I think I finally get it! (Probably because I was using Singletons and didn’t need to pass data between viewcontrollers - I just updated the global object and then had each VC “refresh” when something else changed a value)
    But in my current project, I’ve tried to avoid using singletons and instead I’ve been adding a variable named parentVC to all of my selection screens and then having the callingVC set it equal to “self” right before I present it - that way I have a link to the callingVC. But then in the selection screen class, I’d have to attempt to unwrap the parentVC against 2 or 3 different viewcontrollers to figure out which one it was called by and then call a function in it called “didTapWhatever()”. It was messy and felt wrong - but I didn’t know any other way.
    Now I see how using a delegate simplifies that and makes it much cleaner! Thanks Sean!!!

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

    Thank you so much for making this tutorial! I was struggling for hours but then I watched your video and got my code working shortly after.

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

      Happy to hear it was helpful to you project!

  • @TreyCox1
    @TreyCox1 6 ปีที่แล้ว +3

    I just had my "aha!" moment while watching this video. Super helpful, Sean. Thanks for these videos and for the great podcast.

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

      Awesome! Love those moments 😀

  • @sravk245
    @sravk245 4 ปีที่แล้ว

    Your video tutorials and the comments left by viewers are very informative. I attended an in person iOS course and couldn't really follow my instructors explanation of this topic. Thank you for such a straight forward explanation, very easy to follow.

    • @seanallen
      @seanallen  4 ปีที่แล้ว

      Thanks Srav! Glad you are enjoying the content!

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

    10:44 My heart sank when you said “This function is automatically getting called”. That’s the one part I don’t understand about delegates but it was hand-waved away. Every video so far o delegates does this

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

    So close to 100k subscribers. Congratulations in advance, Sean!

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

      Thanks James!

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

    Keep making Tutorials Sean, you helped me choose my career path and your videos are extremely efficient for learning! Started with your iOS interviews video and now I work as an iOS Developer, dreams do come true and your videos continue to help every time I need to learn!!!

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

      That's awesome to hear Adam! Congrats on the new job!

  • @faizuddin.mohammed
    @faizuddin.mohammed 5 ปีที่แล้ว +1

    HIGHLY RECOMMENDED VIDEO!
    Just had a question regarding Communication Protocols in my technical interview with a large company today.
    I knew the whole concept but couldn't put it into words, wish I had watched the whole series earlier.
    Thanks for the video, Sean.

    • @seanallen
      @seanallen  5 ปีที่แล้ว

      Glad it was helpful... although a little too late it sounds like. 😀

  • @TechyMom-ft
    @TechyMom-ft 2 ปีที่แล้ว +1

    Your teaching method is amazing, loved the video.

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

      Thanks for the kind words, Hiba 😀

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

    Great analogy that clears the air on how delegates work.

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Happy it helped, Pavan!

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

    Thank you so much!! Even after reading bunch of Medium posts, I wasn't clear with the concept of delegates. Thank god I found your life saving video :) Keep making videos, coz you are really good at it!!

    • @seanallen
      @seanallen  6 ปีที่แล้ว

      Thanks Satyam! Glad it helped you out! I know this is a tricky topic.

  • @MarcosVicente0
    @MarcosVicente0 4 ปีที่แล้ว +3

    Hey, Sean! I was really struggling to understand Communication patterns with Delegate protocol. This example and explanation just made very simple to understand. Im definitely
    a video learner. Thank you! Take care!

    • @seanallen
      @seanallen  4 ปีที่แล้ว

      Glad the video helped you out, Marcos!

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

    Nice, concise explanation.
    In the boss code, "we're safe to force unwrap that because we know we have the UIImage..." @7:35. Someone else taught me "Protect yourself against mistyping a UIImage you know you have by safely unwrapping it..." You would hope you'd catch a runtime error like that during testing, but stuff happens.
    p.s. I just noticed Ben Sullivan's comment. That would solve this issue.

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

    It's an oldie but a goodie. Great stuff Sean.

    • @seanallen
      @seanallen  5 ปีที่แล้ว

      Always fun to go back and revisit 😀

    • @chrispy104k
      @chrispy104k 5 ปีที่แล้ว

      Sean Allen
      Truth is that the content was something that I didn’t fully understand despite the courses I have done. Your description gelled immediately so my hats off to you. Happy to have filed that one away for the future.

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

      Many of the topics in programming and iOS development will take repeated study. Glad it was helpful!

  • @shoebmoin10
    @shoebmoin10 6 ปีที่แล้ว +10

    This was the first time i read all the comments of a video , they were very informative thanks for replying all the questions sir :-)

    • @seanallen
      @seanallen  6 ปีที่แล้ว +4

      I can't always get to all of them (some comments are very detailed questions), but I try to get to as many as I can. Happy you appreciate it!

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

    Sean, I always appreciate these videos that you produce. They are very enlightening and have helped me a lot in my iOS development. I'm in the process of switching my career from a PeopleSoft HCM developer to an iOS developer and your videos have pushed me further than I could imagine! Thanks for what you do and keep it up!

    • @seanallen
      @seanallen  6 ปีที่แล้ว

      That's awesome to hear, Trevor! Thanks for the motivating words. Happy to hear I can help. Keep at it!

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

    Superb.. You just put an end to my 3 weeks of stress...! Thanks...

    • @seanallen
      @seanallen  6 ปีที่แล้ว

      Happy to hear it helped, Kristoffer 👍

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

    Perfect!!! Sean, thanks a lot for making this mechanism so clear and easy to understand. Your code and explanations are straightforward and bring it to the point.

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

    Best video on this topic by far. Thank you

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

    As soon as I see its a video made by Sean it gets the like.

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

    This video still saves lives one year after its release...

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

      Hehe, yeah, it's one of my most viewed videos.

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

    Thank you boss (Sean Allen). I (intern/delegate) will implement this lesson right away!

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

    Been struggling with this for a while now, finally makes sense. Thanks Sean!

    • @seanallen
      @seanallen  6 ปีที่แล้ว

      Happy to help, Vu 👍

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

    Love the way you explain, please keep it up!

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Thanks Simon! More videos on the way!

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

    great tutorial ... i am new in IOS development .. your tutorials are really helpful , keep making videos for beginners

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Thanks Charmi! Glad you enjoyed it.

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

    Great video! I finally get the idea of the protocols and delegates. Analogy worked really well. Thank you.

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

    Another one of your videos helping me out of a bind!! Thank you!

    • @seanallen
      @seanallen  4 ปีที่แล้ว

      Happy to help, Chris 😀

  • @TheHy6xD
    @TheHy6xD 7 ปีที่แล้ว +4

    omg, I finally understood how it works, thank you very much!

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Glad to help, Dosbol!

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

    Love your to the point coding videos

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

      Thanks Javad! I do my best to eliminate all the irrelevant stuff.

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

    Thanks for the clear and crispy explaining protocol.

    • @seanallen
      @seanallen  5 ปีที่แล้ว

      Glad you liked it!

  • @sumitbaneedits2721
    @sumitbaneedits2721 4 ปีที่แล้ว

    I am actually an intern learning swift. I am here after my Trainer sent me to learn communication patterns.

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

    Just came across this video again... Wow, just over 2 years since you posted it! Still love the "intern and boss" analogy! 💯

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

      It's a classic... I talk insanely fast... but other than that, I like it.

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

      Yes, these things are evergreen

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

    Nice video! Further extension to this is to have another protocol implemented by Boss so that the communication between Intern and Boss is purely on protocol. For example, Boss would like to pass data (delegate or others) to Intern.

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Thanks for the kind words, D Chu! And you're correct, you could extend this implementation that way.

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

    Great video bro, you're such a good teacher!

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      +Leonardo Emilio Thanks for the kind words! Glad you enjoyed the video.

  • @3ilz
    @3ilz 4 ปีที่แล้ว

    The boss vs intern analogy is genius!

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

    Simply great explanation with rapid speed and a good example(intern - boss)

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

      Thanks Govind! Glad it was helpful👍

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

    You explain really well, Sean. Great video, thanks a lot.

    • @seanallen
      @seanallen  4 ปีที่แล้ว

      Glad you liked it!

  • @MrEcsplorer
    @MrEcsplorer 7 ปีที่แล้ว +4

    Very nice videos. I like your speed. Very logically explained and very supportive analogies.

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Thanks Timo! Glad you enjoyed the video!

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

    Thank you Sean, your explanation was great !

    • @seanallen
      @seanallen  4 ปีที่แล้ว

      Glad it was helpful!

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

    Really great analogy and easy to understand! Love ur channel! I am your observer now 😄

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

      Glad you enjoyed it, Aldo!

  • @WhatIsThisAllAbout
    @WhatIsThisAllAbout 5 ปีที่แล้ว

    watching all the videos, got three interview this Saturday.

    • @seanallen
      @seanallen  5 ปีที่แล้ว

      Good luck! Hope they help.

    • @WhatIsThisAllAbout
      @WhatIsThisAllAbout 5 ปีที่แล้ว

      Thanks Sean. Your videos are amazing. Took a dose of your videos and went high to interview.

  • @johntamch
    @johntamch 7 ปีที่แล้ว +3

    This is by far the best video I found explaining protocols. Thanks Sean and love your interview question videos.

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      That's awesome to hear, John! Glad you're enjoying the interview question videos series.

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

    Your videos are so helpful Sean! Just wanted to say thank you

    • @seanallen
      @seanallen  6 ปีที่แล้ว

      Thanks! Glad you enjoy them 👍

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

    i dont usually comment but when i do it's because its a great video!

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Glad you enjoyed it!

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

    Still helpful in 2020!
    Thanks Sean.

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

      Happy to help 😀

  • @valentinzech8800
    @valentinzech8800 4 ปีที่แล้ว

    Best video on this topic I've seen so far. Thank you!

    • @seanallen
      @seanallen  4 ปีที่แล้ว

      Glad it was helpful!

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

    Such a great video. Very informative and fast paced (in a good way).

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Thanks Laurent! Glad you enjoyed the video and pace!

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

    Dude, you speak so fast sometimes is hard to keep up but great stuff, finally it's all making more sense to me now! Thanks for sharing your knowledge!!

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

      Yeah, these are my older videos. I’ve worked on that in my new ones. It’s much better. See on the comments in this video... this was probably the worst one, lol

    • @jachuonbass
      @jachuonbass 6 ปีที่แล้ว

      I've seen this kind of stuff declare in this fashion right in the middle of a delegate file:
      @objc protocol DataDelegate : class {
      @objc optional func newPrices()
      @objc optional func newHistory()
      }
      does it make any big difference or would you say is pretty much the same principle?

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

      This is declaring the functions as optional. Which means that if you conform to the protocol, you don't HAVE to implement the functions. Where as if you didn't make them optional, and you conformed to the protocol, then implementing the functions would be required.

  • @King-DieGo-12
    @King-DieGo-12 2 ปีที่แล้ว +1

    the tutorial was too good, watched a couple before this one, but only this made sense to me:)

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

      Glad it finally makes sense now, Akash!

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

    Brilliant explanation!

    • @seanallen
      @seanallen  6 ปีที่แล้ว

      Glad you got value out of it, Chris!

  • @CASMANWHAT
    @CASMANWHAT 6 ปีที่แล้ว

    How do you use delegates for the initial screen? where let's say my home screen is a tableview and the moment they click on the cell, the data shows on the next screen? This ex. works for me for second screen binding to first but what about first binding to second? I tried it and I got nil for unwrapping the delegate. Thx for the tutorials they're really good! Gonna support your book!

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

    Just an important tip:
    The 'intern' view controller has to load first. If not, the protocol object will result in a nil error.
    I didn't know this and it took 2 days to figure it out.

  • @Traoreee
    @Traoreee 7 ปีที่แล้ว +14

    Everytime i start to watching your video, i think the video speed is 1.25... Every single time i fall in this mistake haha

    • @seanallen
      @seanallen  7 ปีที่แล้ว +3

      Haha, I've been working on slowing down a bit. Thanks for watching!

    • @coalwood6901
      @coalwood6901 6 ปีที่แล้ว

      yea, no more Sean vids for me....sounds like a gravel hauler droning down the road.

    • @roygalaasen
      @roygalaasen 5 ปีที่แล้ว

      Putting 50% playback speed makes him sound drunk lol

    • @michaelkarbasch7619
      @michaelkarbasch7619 4 ปีที่แล้ว

      I am struggling too haha and on top of that i am a german native speaker which makes it even tougher but great video - thanks for explaning 👍🏻

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

    Great video Sean, thank you ! Subject matter and how you present it (clear, concise) is *very* helpful.
    I have seen (and used in some cases myself) the delegate/protocol pattern where the 'boss'
    class maintains a collection/array of delegates instead of just one. This means that it can support
    one-to-many.
    I don't see this special one-to-many delegate/protocol case useful for the case of a popup communicating
    the result of a choice made, but there are some non-UI cases where this may be suitable - I took this
    approach numerous times in the past instead of the observer/notification pattern as I was porting some
    event listener logic from Java which made use of Java interfaces and since Java interfaces are very similar
    to Swift protocols, I latched on to it.
    Obviously there are some minor differences from your example to support this one-to-many delegate/protocol
    case, notably logic to support multiple delegates - from having to add/remove multiple delegates, to
    invoking *all* the delegates' functions when the time comes. I do this by simply iterating over a delegates
    array, calling each delegate's function.
    QUESTION: I was wondering if you have see this one-to-many case of delegate/protocol usage and if you know
    of any pitfalls to doing it this way vs using the observer/notification pattern.
    Keep up the good work ! Appreciate this video and all the other ones you have made.

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Hey crampsalot, I have not seen this in use in the handful of production apps I've worked on. The projects I've been involved in have pretty much stuck to the delegates/protocols for one-to-one and notifications/observers for one-to-many. Unfortunately, i can't really chime in with an opinion here.

    • @crampsalot
      @crampsalot 7 ปีที่แล้ว

      Sean Allen thank you - appreciate the response.

  • @kimdaegyum
    @kimdaegyum 4 ปีที่แล้ว

    I think the way I processed delegates and protocols is by realizing the view controllers (each different screen) are their own separate worlds.. I used to think everything was one entire thing.. But each screen is its own world that needs to be populated with information from other worlds to make that information catered to the user. So we're passing only the relevant data in order to communicate efficiently. Protocols and Delegates set up the communication link that establishes relationships between the worlds basically - "I expect this kind of data to come my way"

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

    Thanks dude. It helped me understanding it much better.
    I just had an exam in Swift where I was asked about delegates and couldn't answer.🙁

    • @seanallen
      @seanallen  6 ปีที่แล้ว

      Happy to help Mohammed!

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

    I would "like" this video five times if I could.

    • @seanallen
      @seanallen  6 ปีที่แล้ว

      Thanks nipponese. Glad you enjoyed it 😎

  • @MrHyde-kc3dv
    @MrHyde-kc3dv 5 ปีที่แล้ว +1

    really good explanation thanks Sean!

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

    Nice video! Easy to understand

    • @seanallen
      @seanallen  5 ปีที่แล้ว

      Glad you enjoyed it, Alan!

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

    Love how you explain code, good job!

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

    Nice and simple explanation. Thanks!

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Thanks Martin. Glad you enjoyed it!

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

    I wish you made videos like this for MacOS development too. Very clear. I know most of this is similar, but I get some errors that just doesn't make sense.

    • @seanallen
      @seanallen  6 ปีที่แล้ว

      I haven't done any Mac development as of yet. Just iOS

    • @ThinkCleverAndSmart
      @ThinkCleverAndSmart 6 ปีที่แล้ว

      Ok. Would be nice to hear if you ever want to start making some simple apps for the Mac! Swift is extremely similar for both!

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

    Very useful, simple and easy to understand video, thanks!

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

    Hi Sean. Thanks you made it very clear. Keep it up

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      +Klaus Jakobsen Glad you enjoyed it, Klaus!

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

    best explaintion of delegate and protocols 👌👌👌❤❤❤

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

      I have an updated better version on my channel here - th-cam.com/video/qiOKO8ta1n4/w-d-xo.html

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

      @@seanallen thanks but i have already watched that, but didn't got the point before
      i'll watch that again.

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

    Please keep making these videos!!!

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

    you are amazing bro , please come back to swift , we need you

  • @shiviagarwal9134
    @shiviagarwal9134 4 ปีที่แล้ว

    You are a saviour Sean!!

    • @seanallen
      @seanallen  4 ปีที่แล้ว

      Happy to help!

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

    You set up your button action to present the selectionVC. When I tried to recreate the program from scratch to practice what I've learned, I did a control-drag from the button to the selection view and got a segue. I put the = self code into the prepare(for: segue...) function. Is there any value in one approach rather than the other?
    I love the pace and scope of these tutorials.

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Hey Cometmace, they are basically the same. One is a storyboard way of doing it, and the other is just doing it in code. You get the same result.

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

    Hey Sean I found this isolated example super helpful. Great video, thanks!

    • @seanallen
      @seanallen  7 ปีที่แล้ว

      Happy to hear it helped, Christophe!

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

    Man you are rocks! Thank you for your video an explanation, it was helpful

    • @seanallen
      @seanallen  4 ปีที่แล้ว

      Happy to help, Anton!