How to use Protocols in Swift | Advanced Learning #15

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

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

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

    Probably the best Procotols video available on TH-cam!

  • @KimbrellBrad
    @KimbrellBrad 3 ปีที่แล้ว +12

    You are absolutely killing it with this advanced series Nick! Truly appreciate all of the time and effort that you have put into your channel. I have watched every plkaylist and every episode that you have posted. Thanks!

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

      That is an in incredible thing to hear. Thank you for the comment Brad! I could not be happier to hear that someone is actually watching them in order and learning. This keeps me going 😎

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

    That's how Polymorphism is done in Swift. Thanks for the tutorial, Nick! Very good as usual!

  • @bryceellis112
    @bryceellis112 2 หลายเดือนก่อน

    Great Example!! I learned so much in this episode and can't wait to move on to Dependency Injections.

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

    this video is unique from other videos about protocol i ever watched on youtube. thanks man.

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

    Brad is so right. Nick is killing it with awesome well explained, easy to understand tutorials . A truly gifted teacher

  • @Khalid-fm2nh
    @Khalid-fm2nh 3 ปีที่แล้ว +4

    your playlist was by far the best SwiftUi teaching I have ever watched, you don't just explains the concept you even chose to do it by the best practice.
    I hope to see a video explaining how to work with CoreLocation Kit inside MVVM SwiftUI Architecture
    Thank You A lot

    • @SwiftfulThinking
      @SwiftfulThinking  3 ปีที่แล้ว +2

      I am going to add CoreLocation to my list. Maybe a mini-app project. Thanks for the suggestion!

  • @МихаилПеревозчиков-ц4р
    @МихаилПеревозчиков-ц4р 2 ปีที่แล้ว

    Awesome explanation! It was very easy to understand all benefits of it when you had show the usage in Preview. This is a moment when View becomes truly abstractive! Thanks

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

    I love of these videos! Again they are all and I mean all of them very helpful when learning them for the first time and referencing them later on if I forget how to do something. Thank you very much for all your time and effort!

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

      Comments like this are why I've continued posting to this channel. Thank you!!

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

    Great video, everything is explained in simple ways!

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

    Best explanation of protocols I have seen. Thanks, Nick!

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

      Hey William! It's been a while! Thanks for the comment :)

  • @cruiseqe2
    @cruiseqe2 3 ปีที่แล้ว +2

    That was a very clear introduction to an otherwise perplexing subject. Thanks.

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

      Hey Mark! Glad to see you're watching these! Thanks for the comment 👍

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

    As always GREAT explanation. THANK YOU NICK!

    • @SwiftfulThinking
      @SwiftfulThinking  3 ปีที่แล้ว +2

      As always... thanks for watching Anday!

  • @mohamedosama6697
    @mohamedosama6697 2 หลายเดือนก่อน

    I think you applied Strategy design pattern, Good job Nick👏👏

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

    14:15 after using the autofix from XCode, the AnotherColorTheme has primary/secondary/tertiary colors as a var. But DefaultColorTheme and AlternativeColorTheme define them using let. What would be the best practise here ? Make them all three use var or make them all three use let ?

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

      The protocol must be a var, but if your value is a constant, best practice is to keep it a let.

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

    Great video! instead of creating an empty protocol in order to combine 2 other protocols, you can do it via typealias like so:
    typealias CombinationProtocol = ButtonTextProtocol & ButtonPressedProtocol
    and create a variable that conform to it:
    var someVar: CombinationProtocol

  • @BadArt-m7r
    @BadArt-m7r 6 หลายเดือนก่อน

    Super solid. Subscribed!

  • @minimaster.10
    @minimaster.10 ปีที่แล้ว

    keep updating SwiftUI Advance Learning! you are good sensei

  • @BSharing09
    @BSharing09 ปีที่แล้ว

    Best explanation. Thanks a lot.

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

    For the computed properties in the protocol definition in this video example, does 'SET' become implicit property because color is set in the struct?

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

      Hi Usha! Computed properties would be "get" only properties. It wont compile if you set it to get and set.

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

      @@SwiftfulThinking It compiled with 'set'.Can you check that and explain please.

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

    Really solid, clear explanation!

  • @NastyHangover
    @NastyHangover 5 หลายเดือนก่อน

    so long story short we are taking the "how" and replace it by basic rules (get or set for var and existence of func) and type descriptions (var type), so we can inject the how in the beginning of the app, in order to be able to run dummy code. As usual, again big thanks, Nick.

  • @princeabyss4976
    @princeabyss4976 3 ปีที่แล้ว +2

    I can't wait to learn projects from advanced learning, how many learning videos are in this playlist,sir?

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

    So big picture would it be correct to say that protocols help with making sure I'm not making "breaking changes" within my app!?

    • @SwiftfulThinking
      @SwiftfulThinking  ปีที่แล้ว

      Yea it definitely helps for that, but writing tests will also do that (covered later in this course)

  • @Taras195
    @Taras195 3 หลายเดือนก่อน

    So, basically, protocols are just a version of pure-virtual c++ classes?
    Awesome video!

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

    Man . . . You're really good!

    • @SwiftfulThinking
      @SwiftfulThinking  ปีที่แล้ว

      Thanks James!! I’ve been following you’re comments I can’t believe you’re up to this level already 🚀🚀🚀 congrats!

    • @jameskayten6563
      @jameskayten6563 ปีที่แล้ว

      Wow! I wouldn't think you'd any time to read these. Ahh, to be young again!
      I've purchased a bigger keyboard so I can access the arrow keys more easily but the auto completion feature is often confusing me in any case. I must say, I feel a bit sad when you delete all the nice code you've typed - but of course I can always rewind... I was trying to create a color scheme to match the vids but also help me identify the various types in the code. Sorry - I'm starting to ramble. Thanks for the reply Nick!
      @@SwiftfulThinking

  • @magedmohmed4403
    @magedmohmed4403 ปีที่แล้ว

    Thank you Nick , your explanation is very very useful for us

  • @jameskayten6563
    @jameskayten6563 ปีที่แล้ว

    One thing . . . All I can ever find regarding Xcode education is about the iOS. I'm actually more interested in the MacOS and creating desktop applications. There's a demographic that will be increasing of folks who'd rather sit down with a mouse than be fickly-Fudging with thumbs and virtual keyboards. Have any content that you'd recommend or advice on how to proceed most efficiently towards the goal?

  • @kerryferguson8267
    @kerryferguson8267 3 ปีที่แล้ว +2

    Love your videos, thank you for the great explanation! You've briefly mentioned Dependency Injections. Will you be covering Dependency Injection methods like creating Factory classes and/or Dependency Containers in the future? Or is that even relevant in SwiftUI because of EnvironmentObjects, I'm not too sure :/

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

      Haha don't worry, the Dependency Injection video is next!

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

      @@SwiftfulThinking well would you look at that, my dream came true :’)

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

    I actually didn't know protocols can inherit from other protocols. Pretty cool!

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

      Thanks again for the comment James 😎

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

    The best in Swift

  • @indarsnab
    @indarsnab 11 หลายเดือนก่อน

    Amazing, thanks!

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

    Now we’re getting to the juicy part!

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

    Thank you so much....You are amazing teacher

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

    It's nice explanation about protocols , But i have one concern we can also make our Protocols optional for the buttonPressed() function , I think it's good way to reduce the no of lines of code if we make that Protocol optional.please suggest it's a good way or not.

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

    👍🏼👍🏼👍🏼

  • @ekinyil
    @ekinyil 3 หลายเดือนก่อน

    awesome

  • @unrealAbel
    @unrealAbel 11 หลายเดือนก่อน

    ty

  • @nickfloussov185
    @nickfloussov185 ปีที่แล้ว

    There is some confusion about { get }, i.e. why is it possible to 'set' the value of property if it is 'get' only?!
    Why, say, / let primary: Color = .red / generates no error?
    P.S. after some research I've got the answer: protocol "functionality" is applied AFTER struct is initialized,
    i.e. 'primary' property belongs to struct and initialized when related object is already created,
    and protocol's get/set functionality for this (primary) property is invoked/applied later on 😁

    • @SwiftfulThinking
      @SwiftfulThinking  ปีที่แล้ว

      “Get only” means after the initial value is set, you can only get it.
      let primary = .red
      Here you are setting an initial value but the “setter” is disable. Meaning you cannot update / change the value within the protocol

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

    Swift is a protocol oriented langage