Delegate in swift Protocol Pattern Tutorial | Delegate in Swift iOS | Delegate design pattern

  Рет қаралды 19,220

Code Cat

Code Cat

Күн бұрын

Пікірлер: 64
@CodeCat15
@CodeCat15 5 жыл бұрын
The delegate pattern is just like the function pointers in c and c++ but usually explained with a ton of high-funda technical words, but codecat15 always tries to make and explain things in the simplest way so that young developers can leverage this pattern and understand the actual meaning of this. I hope you not only learn but understand this pattern and use it in your project. You may download the source code files from the description link and play with it. Part 2 of this video is coming soon. Until then please subscribe to the channel if you find this helpful in understanding swift in a simple way 👍 And don't hesitate to ask me any questions via comments or on the email.
@vyankateshshivnikar7932
@vyankateshshivnikar7932 2 жыл бұрын
Please make a video on autolayout
@diliptilonia
@diliptilonia 4 жыл бұрын
ab tak mai, jab bhi data transfer karna hota tha to main blindly delegate & protocol ke path use karta the, but now I understand the actual mean of it when you did without protocol, thanks for sharing your knowledge.
@CodeCat15
@CodeCat15 4 жыл бұрын
@Dilip: closures vala bhi video dekhna coz usmai maine comparison kiya hai delegate and closure approach ka. Aapne ios group k saath bhi share karna.
@hardipgajera2316
@hardipgajera2316 4 жыл бұрын
your teaching way is clean and very powerful !! please keep it up
@CodeCat15
@CodeCat15 4 жыл бұрын
Thank you Hardip for your kind words 😊 if you have any questions then please feel free to ask
@jaisinghsisodia8202
@jaisinghsisodia8202 4 жыл бұрын
Now i got whole understanding of custom delegate and where we have to use that . I like the way you relate each concept with our daily life example which trigger quickly.Thanks a lot buddy
@CodeCat15
@CodeCat15 4 жыл бұрын
There’s also a video on closure delegate pattern where am comparing delegates done via closure and protocols, do check that out as well. And thanks a lot for the kind words 😊 I try to simplify things by connecting them with the real world coz that way you remember the actual usage than some bookish verbiage Link: kzbin.info/www/bejne/i5LJfZyIq6eqhKM
@jaisinghsisodia8202
@jaisinghsisodia8202 4 жыл бұрын
@@CodeCat15 Ya i went through with that video and also referring all your videos .
@CodeCat15
@CodeCat15 4 жыл бұрын
Cool feel free to ask questions if you have any will be happy to answer them
@natureloverspakistan
@natureloverspakistan 5 жыл бұрын
simple and straightforward .. nice tutorial .. please also make a tutorial on weak, strong, unowned etc.. we cannot explain to interviewer when they asked about that :(
@CodeCat15
@CodeCat15 5 жыл бұрын
Ok no worries, I will highlight this topic in my upcoming video as well. Thank you for bringing this up I will add it in my list.
@mohittomer9232
@mohittomer9232 3 жыл бұрын
You make a really very awesome videos, I have watch your 6--8 videos that really helpful for me. Keep it up bro. Thanks for these contents.
@CodeCat15
@CodeCat15 3 жыл бұрын
Welcome to the channel Mohit, I am glad these videos are helpful. Please feel free to ask questions and do share the same with your iOS group.
@shahzaibqureshi6192
@shahzaibqureshi6192 11 ай бұрын
Bhai kia mast samjhatay ho yr aap. bht aala
@CodeCat15
@CodeCat15 11 ай бұрын
Thank you :)
@rohitnishad5261
@rohitnishad5261 3 жыл бұрын
Your all video great bro
@CodeCat15
@CodeCat15 3 жыл бұрын
Thank you, am glad they are helpful
@rishilund4120
@rishilund4120 3 жыл бұрын
Bhai the main thing is you take exaples and you teach us from the basics keep continue your work
@CodeCat15
@CodeCat15 3 жыл бұрын
I am glad this was helpful Rishi, please feel free to ask questions and do share the video with your iOS group
@rishilund4120
@rishilund4120 3 жыл бұрын
Definitely bro
@arbintajnawaz7200
@arbintajnawaz7200 4 жыл бұрын
Thank God finally I found one quite understandable video . Keep it up😀😀😃😃😃
@CodeCat15
@CodeCat15 4 жыл бұрын
Welcome to the channel Arbin, i am glad this video was helpful. Plz feel free to ask questions on the topic and do share the video with your iOS group on WhatsApp or Facebook
@shivshankargupta4051
@shivshankargupta4051 4 жыл бұрын
Thanks man, finally clear all doubts.
@CodeCat15
@CodeCat15 4 жыл бұрын
Hey @Shivshankar welcome to the channel, do feel free to ask questions on this topic and do subscribe and share this channel with your iOS group
@samargupta7355
@samargupta7355 4 жыл бұрын
Hey you are so good, Keep it up. Doing great job man.
@CodeCat15
@CodeCat15 4 жыл бұрын
Hello @Samar welcome to the channel. Thanks for the kind words and please do ask questions on this topic if you have any. I recommend watching the closures delegate video as well so that you get a good grip between closure vs protocol delegate pattern too. Please do subscribe to the channel and do share it with your iOS group over WhatsApp or Facebook or anyone who wants to learn swift programming 🙏
@natureloverspakistan
@natureloverspakistan 5 жыл бұрын
i anyways implement delegates using protocol ..another toist from my side vc class ko tableview cell me as a reference pas ker ke vc class ke function call kiye the leki mujh ye approach sahi nae lgi.. r sch me pehly mujh pta b nae tha ...ye b pure delegate pattern approach he .. :p thanks for sharing valuable information
@sunishram85
@sunishram85 Ай бұрын
Hi, Please make video on AppDelegate vs SceneDelegate
@raviborad2661
@raviborad2661 3 жыл бұрын
Thanks, Mate, Good explanation :)
@neerajgupta8241
@neerajgupta8241 4 жыл бұрын
very good explanation.
@CodeCat15
@CodeCat15 4 жыл бұрын
Thanks Neeraj
@MithleshKumar-qn6ki
@MithleshKumar-qn6ki 4 жыл бұрын
Great work man! Keep it up 👍
@CodeCat15
@CodeCat15 4 жыл бұрын
Thanks Mithlesh and welcome to the channel. Hope this video gave you all the details you were looking for and if not then plz do feel free to ask questions about it I will be happy to answer them. Do share this channel with your iOS group on WhatsApp or Facebook 😊
@AhsanZahidDevb
@AhsanZahidDevb 4 жыл бұрын
The best explanation and Nice Tutorial 👍🏻 Goku is also my favorite 😉
@CodeCat15
@CodeCat15 4 жыл бұрын
Nice dragon ball z was my first anime but on the longer run i started liking vegeta, as of now watching black clover and just finisher attack on titans and Naruto apart from that do ask questions on delegates if you have some 👍
@puneetbhagat7691
@puneetbhagat7691 5 жыл бұрын
Thanks sir to share the awesome lecture 👍👍🙏🙏🙏
@CodeCat15
@CodeCat15 5 жыл бұрын
@Puneet: Thank you Puneet, am glad it helped. If you have any questions then don’t hesitate to ask.
@rehanismail7082
@rehanismail7082 4 жыл бұрын
Best explanation love your tutorials @Code Cat
@CodeCat15
@CodeCat15 4 жыл бұрын
Hey @Rehan welcome to the channel and thank you for your comments, please feel free to ask questions and do subscribe to the channel and share this video with your iOS group on Facebook or WhatsApp or whoever wants to learn
@garimavishwakarma337
@garimavishwakarma337 Жыл бұрын
sir, can we communicate with more than two classes at the time using prototcol and delegate method?
@CodeCat15
@CodeCat15 Жыл бұрын
delegate can give you the result of a particular operation so what you can do is perhaps create a wrapper where you can call multiple classes and once you get the responses from those classes then in that case you can pass this response to the delegate accordingly, this is a design problem and perhaps if you email me what you are looking for and what have you tried I can do a quick review when I get time.
@nehajain4736
@nehajain4736 3 жыл бұрын
Hello Ravi, Your explanations are really good and very understandable too. I found a point in this video which is required bit more clarification which I want to highlight here. You started with an approach where you were not using . After that you specified reason, why we should use and that reason was to avoid human error regarding function declaration. Might be developer forgot to write function. That is right but can you specify a bit more like - As per my understanding, we use that keyword it give/provide us flexibility to add required function directly while you add/Fetch protocol in your class. So that, developer will never forget to implement that function whenever/where ever, he/she required it and through this we can maintain function names as well. If I said something wrong please correct me. Thanks for your videos. Your videos are really good and admirable.
@CodeCat15
@CodeCat15 3 жыл бұрын
what you said is true, and that too is a human error that you are trying to avoid as well, the main role of a protocol is to implement a set of common functions that you will use in your module and then enforce the developer to use them. One more reason here is that if you use protocols you achieve abstraction. Protocols can be used in many ways if you watch my latest video on concurrency with core data there you will get more insights on a real project scenario to use protocols and also to implement ISP principle. I hope I was able to answer your question and if not then please feel free to ask more questions. Welcome to the channel Neha
@nehajain4736
@nehajain4736 3 жыл бұрын
@@CodeCat15 Thanks for your reply yes my doubt is clear now. 😊
@ganesha3559
@ganesha3559 2 жыл бұрын
Sir, very good explanation. I really like your video especially the flow of explanation with analogies :) Kindly keep up the good work. I had 1 question: it might be silly but still worth a shot. Since the Developer Instance is getting created inside Manager anyways, why cant Developer simply return the value of the addition?
@CodeCat15
@CodeCat15 2 жыл бұрын
let's go by your approach, how do you think the developer would return the response from it's function without creating a reference inside the manager? You can't without the instance of the developer so we create the developer instance inside the manager, however this was just a demo and if your class has a dependency then that dependency must be injected that created inside a function or class. Let me know if this answers your question and if not then please ask more.
@ganesha3559
@ganesha3559 2 жыл бұрын
​@@CodeCat15 I dont fully understand. So i made a GIST to convey my question. gist.github.com/ganeshsacharya/1b7fbcd7f0cbd5b439c5853f0f15ee6e Can you take a look?
@shiviparashar7419
@shiviparashar7419 3 жыл бұрын
Why we use weak keyword only with class?
@CodeCat15
@CodeCat15 3 жыл бұрын
Class are reference type and they can create a reference cycles which leads to memory issues so to make sure reference cycles are not created we have to explicitly specify that they am using weak reference here and once you move out of the closure scope the reference is destroyed avoiding any memory leaks. Let me know if that answers your question Shivi and welcome to the channel
@YourLeader350
@YourLeader350 4 жыл бұрын
What do you does. I means are you app developer . In which company .or online developer plz make motive video on chain on what we do by chain after what we will should do
@CodeCat15
@CodeCat15 4 жыл бұрын
Hello Usama, welcome to the channel I am a full stack developer, can you explain more what you mean by chain?
@shreyasinharoy2362
@shreyasinharoy2362 3 жыл бұрын
what is the difference between delegate and protocol?
@CodeCat15
@CodeCat15 3 жыл бұрын
Delegate is a design pattern, protocol is a type through which we can achieve that pattern and hence its called delegate protocol, the same delegate pattern can also be achieved via closures so you may come across some developers saying delegate closure protocol as well.
@AnkitGupta-hv2xe
@AnkitGupta-hv2xe 3 жыл бұрын
I saw some of your videos and I love the way of explanation. Thank you Sir. 100 👍 for CodeCat15.
@CodeCat15
@CodeCat15 3 жыл бұрын
I am glad these videos are helpful Ankit, do share them with your iOS group too and feel free to ask questions
@pratikgajbhiye5354
@pratikgajbhiye5354 4 жыл бұрын
What is 15 after CodeCAt
@CodeCat15
@CodeCat15 4 жыл бұрын
hey there, welcome to the channel, I like coding and cats and my date of birth is 15 so the channel name is codecat15 😊 Do feel free to ask questions and share this channel with your iOS group or any iOS group on Facebook and what’s app
@abbasgujjar6057
@abbasgujjar6057 4 жыл бұрын
Please send your Linked In Profile link
@niharsaxena9029
@niharsaxena9029 2 жыл бұрын
Using class is not a good method:- "Using 'class' keyword to define a class-constrained protocol is deprecated; use 'AnyObject' instead" ... Otherwise this warning will show
@Roland_Garcia
@Roland_Garcia Жыл бұрын
This video need CC! Kkkk
@CodeCat15
@CodeCat15 Жыл бұрын
Will work on it, apologies for the inconvenience caused
@amy1119991
@amy1119991 4 жыл бұрын
Not that great explanation! but serves the purpose!
@CodeCat15
@CodeCat15 4 жыл бұрын
Hey @Amol thanks for the feedback can you explain what can be improved in the explanation I would like to improve for future videos and try to avoid doing those mistakes. Thanks
How to create and use protocols - Swift for Complete Beginners
17:23
Swift Generics: The Key to Reusable and Flexible Code
23:47
Swift and Tips
Рет қаралды 7 М.
Solving one of PostgreSQL's biggest weaknesses.
17:12
Dreams of Code
Рет қаралды 223 М.