How to use Protocols in Swift | Advanced Learning #15

  Рет қаралды 15,393

Swiftful Thinking

Swiftful Thinking

Күн бұрын

In this video we jump into the wild world of Protocols in Swift. We will learn how to create custom protocols and then walk through a few real-world implementations.
Apple's definition of a Protocol:
A protocol defines a blueprint of methods, properties, and other requirements that suit a particular task or piece of functionality. The protocol can then be adopted by a class, structure, or enumeration to provide an actual implementation of those requirements. Any type that satisfies the requirements of a protocol is said to conform to that protocol.
🤙 WELCOME BACK 🤙
WEBSITE: www.swiftful-thinking.com
DISCORD: / discord
GITHUB: github.com/SwiftfulThinking/
SAY THANKS: www.buymeacoffee.com/nicksarno

Пікірлер: 56
@Pepe_the_raver
@Pepe_the_raver 9 ай бұрын
Probably the best Procotols video available on KZfaq!
@KimbrellBrad
@KimbrellBrad 2 жыл бұрын
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 2 жыл бұрын
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 😎
@bbulliard
@bbulliard 2 жыл бұрын
Brad is so right. Nick is killing it with awesome well explained, easy to understand tutorials . A truly gifted teacher
@arkemal
@arkemal Жыл бұрын
That's how Polymorphism is done in Swift. Thanks for the tutorial, Nick! Very good as usual!
@Khalid-fm2nh
@Khalid-fm2nh 2 жыл бұрын
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 2 жыл бұрын
I am going to add CoreLocation to my list. Maybe a mini-app project. Thanks for the suggestion!
@user-do2un1cd4e
@user-do2un1cd4e Жыл бұрын
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
@probe8668
@probe8668 2 жыл бұрын
this video is unique from other videos about protocol i ever watched on youtube. thanks man.
@lionsctn5053
@lionsctn5053 2 жыл бұрын
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 2 жыл бұрын
Comments like this are why I've continued posting to this channel. Thank you!!
@asigivati1382
@asigivati1382 2 ай бұрын
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
@andayismayilzade1897
@andayismayilzade1897 2 жыл бұрын
As always GREAT explanation. THANK YOU NICK!
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
As always... thanks for watching Anday!
@williamallen4607
@williamallen4607 2 жыл бұрын
Best explanation of protocols I have seen. Thanks, Nick!
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Hey William! It's been a while! Thanks for the comment :)
@user-ic8sm9pw4r
@user-ic8sm9pw4r Ай бұрын
Super solid. Subscribed!
@magedmohmed4403
@magedmohmed4403 9 ай бұрын
Thank you Nick , your explanation is very very useful for us
@indarsnab
@indarsnab 5 ай бұрын
Amazing, thanks!
@cruiseqe2
@cruiseqe2 2 жыл бұрын
That was a very clear introduction to an otherwise perplexing subject. Thanks.
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Hey Mark! Glad to see you're watching these! Thanks for the comment 👍
@BSharing09
@BSharing09 Жыл бұрын
Best explanation. Thanks a lot.
@minimaster.10
@minimaster.10 8 ай бұрын
keep updating SwiftUI Advance Learning! you are good sensei
@ericweideman6626
@ericweideman6626 2 жыл бұрын
Really solid, clear explanation!
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Thanks for watching Eric 😎
@thahiraf1317
@thahiraf1317 2 жыл бұрын
Thank you so much....You are amazing teacher
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Thanks Thahi!
@jameskayten6563
@jameskayten6563 10 ай бұрын
Man . . . You're really good!
@SwiftfulThinking
@SwiftfulThinking 10 ай бұрын
Thanks James!! I’ve been following you’re comments I can’t believe you’re up to this level already 🚀🚀🚀 congrats!
@jameskayten6563
@jameskayten6563 10 ай бұрын
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
@mrslana3049
@mrslana3049 2 жыл бұрын
The best in Swift
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Thanks Mrs Lana!
@KanoKendama
@KanoKendama 2 жыл бұрын
Now we’re getting to the juicy part!
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Haha I hope you're ready Ken!
@cinquain0
@cinquain0 2 жыл бұрын
I actually didn't know protocols can inherit from other protocols. Pretty cool!
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Thanks again for the comment James 😎
@kerryferguson8267
@kerryferguson8267 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 2 жыл бұрын
Haha don't worry, the Dependency Injection video is next!
@kerryferguson8267
@kerryferguson8267 2 жыл бұрын
@@SwiftfulThinking well would you look at that, my dream came true :’)
@abelhancco4349
@abelhancco4349 6 ай бұрын
ty
@mhfs61
@mhfs61 2 жыл бұрын
👍🏼👍🏼👍🏼
@kuldeepbhandari7276
@kuldeepbhandari7276 Жыл бұрын
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.
@princeabyss4976
@princeabyss4976 2 жыл бұрын
I can't wait to learn projects from advanced learning, how many learning videos are in this playlist,sir?
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
There will be about 20 total 😅
@tbg6nb
@tbg6nb Жыл бұрын
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 Жыл бұрын
The protocol must be a var, but if your value is a constant, best practice is to keep it a let.
@jameskayten6563
@jameskayten6563 10 ай бұрын
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?
@chrisstromberg6527
@chrisstromberg6527 Жыл бұрын
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)
@ushadesai6306
@ushadesai6306 2 жыл бұрын
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 2 жыл бұрын
Hi Usha! Computed properties would be "get" only properties. It wont compile if you set it to get and set.
@ushadesai6306
@ushadesai6306 2 жыл бұрын
@@SwiftfulThinking It compiled with 'set'.Can you check that and explain please.
@SiamakAshrafi
@SiamakAshrafi 2 жыл бұрын
Swift is a protocol oriented langage
@nickfloussov185
@nickfloussov185 6 ай бұрын
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 6 ай бұрын
“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
How to use Dependency Injection in SwiftUI | Advanced Learning #16
35:32
Swiftful Thinking
Рет қаралды 27 М.
Why Is He Unhappy…?
00:26
Alan Chikin Chow
Рет қаралды 67 МЛН
Sort, Filter, and Map data arrays in Swift | Continued Learning #13
28:36
Swiftful Thinking
Рет қаралды 20 М.
How to create and use protocols - Swift for Complete Beginners
17:23
Protocols and Polymorphism in Swift | Protocol Oriented Programming
11:58
UI Testing a SwiftUI application in Xcode | Advanced Learning #18
1:36:58
Swiftful Thinking
Рет қаралды 21 М.
Create custom Bindings in SwiftUI | Advanced Learning #27
30:41
Swiftful Thinking
Рет қаралды 4,7 М.
Advanced Swift L3 - Hashable
20:52
AppleProgramming
Рет қаралды 3,5 М.
AMATEUR VS PRO: Protocol Oriented Programming Swift
20:42
Rebeloper - Rebel Developer
Рет қаралды 3,6 М.
Unit Testing a SwiftUI application in Xcode | Advanced Learning #17
1:47:03
Swiftful Thinking
Рет қаралды 35 М.