Model view controller MVC design pattern in Swift iOS (Hindi tutorial)
Вставка
- Опубліковано 2 сер 2024
- Model view controller or MVC is the default design pattern of iOS apps, MVC in swift programming can be implemented using the various features mentioned in the Apple developer documentation. But just implementing MVC design pattern ios swift is not enough one must also follow good programming principles to make sure that they have less coupling in their code.
This MVC in swift hindi tutorial with easy examples helps beginners to understand this design pattern and implement it using the right techniques in their project. The model view controller example in this video will guide you in making the right set of decisions while implementing this pattern.
Model view controller swift is an excellent pattern for your project but it depends on how you implement to avoid massive view controllers.
In this MVC swift Hindi tutorial I will be explaining the core concepts of MVC along with how you should not implement MVC and on that note let's have a look at the categories that we will cover today
0:00 Introduction about the video
0:42 Summary about today's topic
1:54 Model View Controller explained
2:02 Why implement a design pattern
2:39 History of MVC
3:20 Model in swift MVC and its responsibilities
5:57 View in swift MVC and it's responsibilities
7:04 Controller in swift MVC and its responsibilities
8:41 Incorrect implementation of MVC iOS app code review
13:04 Does MVC cause a massive view controller?
14:46 Dividing responsibilities across layers
17:25 My opinion on MVC
Apple MVC documentation: developer.apple.com/library/a...
Apple View Container documentation: developer.apple.com/library/a...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
✅ Subscribe to the channel and stay ahead of everyone by following the right way for writing clean code in swift. 🔥🔥🔥🔥🔥
🔗Click on the link to subscribe: ua-cam.com/users/codecat?sub...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----------------------------------------------------------------------------------------------------------------------
📥 Download the source code from
Github: github.com/codecat15/UA-cam-...
Google Drive: drive.google.com/file/d/1HB2B...
-----------------------------------------------------------------------------------------------------------------------
🎶 Royalty-free Music: www.bensound.com
############################################
Connect with me on social media
Instagram: / codecat15
📧: codecat15@gmail.com
🐦: / codecat15
Facebook: / code.cat.792
Github: github.com/codecat15
###########################################
#mvcSwiftExample #mvcInSwiftInHindi #mvcSwiftBeginners
Next Level Video, Thanks.
Welcome 🙏
I really appreciate the way you explain things. Thank you so much!!
Perfect bhai cant thanks much for this
Happy this video was helpful Rishi 👍
Very clean and simplest explanation I have ever seen. Thanks a lot Code Cat.
Glad you liked it 😊
Very Informative and clean understanding, I have ever seen.👍
Feel free to ask questions on the topic and do share the content with your iOS group. I hope this channel provides more insights and details for every topic that you search.
are bhai kya mast banate ho videos zbardat
👍🏼👍🏼👏🏻👏🏻Great Video
Great explanation as always ✌️.
Thanks waseem am glad this was helpful, do ask questions on this and feel free to share it with your iOS group
Very nice explaination....Thanks Ravi...
Glad it was helpful
very informative and waiting for the next session. 👌
Thanks Hardip am glad this video was helpful do feel free to ask questions on this and share it with your iOS group on WhatsApp or Facebook
Thanks for your excellent explanation
Welcome to the channel Bishal, I am glad this video was helpful do watch the second part of this video which is decomposition with MVC, I am sure you will get more insights in that video as well. Do share the video with your iOS group on whatsapp or facebook and feel free to ask questions
Apart from explaining things in such a detail 👌..
You always introduced us with some new terms and concepts. 🤘✌
I am glad this video helped, and the concepts were already there from day 1 and it's quite sad that nobody reads the documentation where apple has mentioned a ton of good practice to improve our code
Part of the problem is we just jump to code rather than doing system design or how your code flow will be if we all start doing that the code quality and the productivity of the team will drastically increase.
Please do share this video with your friends and help them to learn MVC using the right techniques and as always feel free to ask questions :)
very good
Thank you so much for this video
I am glad this was helpful pratik do feel free to share this video with your iOS group and do feel free to ask questions on this topic
thanks. finally, it is making sense.
Do checkout the second part of the video which is decomposition in mvc to see how you can arrange your code and make it less tightly coupled
Thank you for sharing knowledge 🤝
I am glad it was helpful Akash
Than you ravi. I appreciate the effort
I am glad these videos are helpful
Totally agree with your point Ravi. I am working on iOS for more than 10 years . MVC is not bad, the way we write code makes it bad. And lastly we start complaining MVC is massive view controller. Love the way u explains things
One more thing that I wanted to add to this video was how some creative devs just to try new patterns defame an old pattern and I think that's not a good approach. We should know in detail about the patterns, what problem they solve, how to implement them in their respective technology with good software engineering principles, else it would be the classic case of removing a screw by using a hammer, a hammer is used for a different case to remove a screw we need a screwdriver. I am glad this video was helpful to you Saif, please do share this with your iOS group
@@CodeCat15 totally agree. Surely I will share it .
very good explanation
Thanks Rohit, please do feel free to ask questions and do share it with your iOS group on WhatsApp or Facebook
Do you have any video on VIP or VIPER ? If Not can you make it, though I have gone trough several tutorials but missing your simple/clean explanation.
Nice
This is show your hard work
Thanks Shahbaz
A very nice, experienced person can also take help from this.
I am glad the video was helpful Anil, welcome to the channel
Nice explanation , Is there any disadvantage for MVC?
I don’t really think so, if a dev is facing issues like massive view controller or anything else its probably because they have not structured their code well or followed any design patterns.
it was good, and i can't wait for next part of it. so can you tell me when will it come?
Hey there, welcome to the channel am glad this video was helpful to you. I will try to release the second part by Sunday or max by Monday next week. Until then plz do feel free to ask questions on this topic and do share it with your iOS group on WhatsApp or Facebook 👍
Ok thanks, 👍
Could you please make a video regarding MVVM also.
Hello Rohit welcome to the channel, i did make 3 videos on mvvm and here’s the playlist for the same
Playlist mvvm: ua-cam.com/play/PLb5R4QC2DtFs8CsVZztGSJ0TM8J2URfg7.html
Which is the best way to create view, xib or programmatically
I think it depends, you can use storyboard and xibs for uikit based project.
For larger projects i would never recommend storyboard coz for larger projects they give rise to a different problem, but if you look at swift ui i think apple wants us to use code for creating ui.
Second part kb aayega? Excited for that. ✌️
mostly next week, next week to clean code pe hoga but what's really interesting is the container and child view controller concept coz using those two concept the UI code can be managed more effectively, Apple's documentation is very detailed on that concept I did share the link in the video description for the same
Yes i want to know that. I have Idea of mvc and mvvm but this basic logics are must have to know.
Yup, i think i did see latest and old video and blog tutorials and they do not explain model controllers and container views its only when you know about these two terms you can search them, i wanted to make sure i atleast introduced them in this video so that i can remember to make videos on them later
One quick question, as you said in the video that we need separate layer for Business logic, Validations and api calls which is valid but how do you convince this to the interviewer because as per MVC, business logic is a part of Model.
Please clarify and support your explaination with apple point of view.
What happens when you want to share the same business logic with 10 models?
What will be your approach if you keep BL (business logic) inside models?
You will end up copy pasting the same code in all those layers breaking DRY principle and this is bad
Not only that, the code is now tightly coupled to all those models and we have zero reusability.
Your business logic is now scattered across the entire application than being centralized
Imagine what happens when the BL needs to change? What then?
A new developer can easily mess things up if they forget to make change to all those 10 models same goes for the dev who worked in the project
I agree to most of what apple mentions in their docs but then I disagree that BL should be inside models and the above is my technical reason for the same.
@@CodeCat15 Thank you so much for quick reply and also for the descriptive explanation. Also, putting your reviews/opinion in the end of the video helps, you don't only read the said things, you also optimize by including the last part.
I am at 14:09 and if i see image and my room, both are same.
Hehe 🙃
Waiting for SwiftUI content? I think you should make 3 to 5 video in a week.
Man i only wish that was the case coz i love to do that but i am not a full time youtuber and i get time only on weekend to make videos due to work but i been working and learning swift ui and must say its really amazing
i am having one doubt how it is different from MVVM . mvc me controller and mvvm me view model both are handling same thing suppose i have a validation which i can create diff file for validating and other logic related things in separate file i can call from controller or view model then how is it different not able to understand what is the difference ..BTW nice video i liked your explanation
controller should have one responsibility which is to request data for its UI components and that's all anything you add extra in the controller is a complete violation of its responsibility. Apple has its own flavor of MVC to tackle few things as you may have seen in the video but then too everyone just dumps everything inside the controller and then blames how troublesome MVC is, and if you think MVVM is awesome well now whatever creative devs dumped inside the controller making it massive now the same dumping is happening in view model, so it all boils down to understanding the responsibility of those layers and implementing them accordingly.
bro but what should be the appropriate answer for the difference between MVC and MVVM, specifically with respect to ios development@@CodeCat15
@CodeCat15 waiting for your reply here for answer for the difference between MVC and MVVM, specifically with respect to ios development, please reply
Hello Ravi
Suppose, in my project uses 40-50 apis. then i create 40-50 resource file. is this oky?
Hey Bhavesh thanks for asking this. The answer is NO. Out of those apis there will be few which belong to the same entity like for example
1. Get employee
2. Update employee
3. Delete employee
4. GetEmployeeWithDepartmentId
so these are 4 separate APIs but they belong to the same entity which is Employee so you create a single resource file for them with the name EmployeeResource and add these 4 Apis there same goes for any other entity.
Let me know if that answers your question and if not plz feel free to ask more
@@CodeCat15 Thanks Ravi
Hello Ravi,
I understand this but if more entity in project and so i create more file that is any disadvantage.
My question is separate class has separate file.
So is your concern creating more class in your project? Or creating more swift files?
@@CodeCat15 its nearly 100 entity. so create 100 separate file for each class. It is oky?
I was google but some person say it good to decompation and some says not to longer good.
Sorry to bug you again, but can you please share a git project or a video to show how mvc following project with hierarchy should look like? Its fine, even if the files and folders are empty but hierarchy is what i need to know.
Let’s do this, add in your understanding of this hierarchy and I’ll add corrections to it if needed.
Isn't MVC is architectural pattern instead of design pattern ?
Apple calls it a design pattern for some reason so I went with that. However it’s an architecture pattern coz it deals with organizing the folder structure.
OK. Btw, thanks for giving us free education.
@avii___7 Welcome 😊