How to Use MVVM (Model View ViewModel) in Swift & iOS - 2023

  Рет қаралды 57,957

iOS Academy

iOS Academy

Күн бұрын

Model View ViewModel is a popular design pattern used in iOS Development. Learn the ins and outs of MVVM through a real world example. Build sustainable, maintainable, and large scale projects with this awesome coding approach!
💻 Source Code: / iosacademy
🎥 Subscribe for more: kzfaq.info?su...
😎 Like my teaching style? Check out some of my most popular courses!: courses.iosacademy.io
👉🏼 Connect (personal LinkedIn) / afrazsiddiqui
🚀 Follow on LinkedIn / ios-academy
iOS Academy offers the #1 course for iOS Development for Beginners. Learn to create iPhone and iPad apps from scratch. Everyone these days has an app idea; learn the important skill of making those apps, make yourself more marketable, change industries to get a different job, and enjoy the ride!
This video is brought to you by Skillshare - an only community of teachers sharing awesome skills. Use the following link to get 2 months of FREE premium: www.skillshare.com/r/user/afraz

Пікірлер: 86
@multitudes389
@multitudes389 4 жыл бұрын
without zooming in and out all the time would be easier to follow. getting dizzy here 😀
@iOSAcademy
@iOSAcademy 4 жыл бұрын
Haha thanks for the feedback. Newer vids have less zooming :)
@rishilund4120
@rishilund4120 3 жыл бұрын
@@iOSAcademy Dont do it we dont want the zoom thing please
@ConernicusRex
@ConernicusRex 2 жыл бұрын
@@rishilund4120 No. Nobody does. Stop.
@gumstuckinmypocket
@gumstuckinmypocket 2 жыл бұрын
wacky zooming is making me see-sick. ugh
@michaelsanford5233
@michaelsanford5233 2 жыл бұрын
Quickly history lesson: Apple acquired NeXT Computer in 1996 Before Xcode, there was Project Builder and Interface Builder. nib = NeXT Interface Builder. Xcode merged Project Builder and Interface builder into one app and nib file format changes to XML. xib = XML Interface Builder. NSString = NeXT Step String.
@muhammadharoon7928
@muhammadharoon7928 3 жыл бұрын
Hi, The tutorials is very helpful and informative, bu the zoom level is too close and i got lost and difficult to catch the actions. @ios Academy: - Please try to zoom out for easily understandable and follow the procedures.
@harolddavidson5598
@harolddavidson5598 Жыл бұрын
Agreed. The zoom on this one was a little too much. Hard to pause and copy what was being done if following along.
@hasanbasriozturk1550
@hasanbasriozturk1550 3 жыл бұрын
I love how you sum things up in a video shorter than 20 minutes. Keep on doing the good work please
@xchen430
@xchen430 2 жыл бұрын
Should the ViewController still hold a reference to the model array (Person in this example) in MVVM? Also do network calls go in VC or VM?
@IraniyaNaynesh007
@IraniyaNaynesh007 3 жыл бұрын
How can we update the model from user action lets say I'm showing some list which has a fav button so when the user clicks on fav in the cell I want to update the model, So what's the best way to update using MVVM,?
@abdullahkidwai7222
@abdullahkidwai7222 4 жыл бұрын
Hello I am getting the following error: Thread 1: Exception: "unable to dequeue a cell with identifier CustomeTableViewCell.cellIdentifier - must register a nib or a class for the identifier or connect a prototype cell in a storyboard" Your help would be appreciated.
@krishanmadushanka9521
@krishanmadushanka9521 3 жыл бұрын
Where do we write the business logic in mvvm? In some articles it says Model and in some other articles it says Viewmodel.
@hustlas4ever
@hustlas4ever 4 жыл бұрын
Hi! Thank you so much. If you have time please expand this. Like how do we arrange the project structure using MVVM?. Thanks. Am I too demanding? Sorry lol but I really like your pace and how easy to understand your explanations. Thanks again, we really appreciate it.
@iOSAcademy
@iOSAcademy 4 жыл бұрын
Youre welcome! And you aren't demanding at all! I love getting suggestions :) Glad you like to help
@alobaili
@alobaili 4 жыл бұрын
Thanks for the video. Great content! Here's my note: The view controller class had more lines now. I could have left it accessing the model object directly and take what property I want. I didn't get why having a middleware object which is the view model makes the code cleaner. Even if the person object had 100 properties I can still get the 2 I wanted without having to implement a view model object. Because I'm still a beginner in iOS development (only about a year into it), maybe I need to work on more projects to see its value.
@iOSAcademy
@iOSAcademy 4 жыл бұрын
Great question - and actually you're observation is correct. You can in fact use the model directly like MVC but here is why that is not advised. There are cases where one underlying model, maybe like a singleton owned model, could be driving multiple view controllers and views. Let's say a network call updated that model with a certain property and only one view needs to be refreshed. It becomes hard to isolate those view update operations - enter viewModels. For thise case, say we have 12 views powered by data belonging to 1 model - if we only have 1 property update on one viewModel, we know what view it ties to. With large projects at scale, this saves us a ton of complexity and frankly makes smaller (viewModel) objects to work with. Hope that helps :)
@markyjordan
@markyjordan Жыл бұрын
Hi! Thank you for the tutorial! I was wondering, how does the viewModel you introduced make the ViewController less massive? Thank you :)
@aparnarvd4343
@aparnarvd4343 2 жыл бұрын
Great tutorial, thank you for sharing the information. Like you said 1. Can we use MVVM for large/bigger projects which are going to use the app in millions? 2. Is this design pattern useful for any specific domain apps? Please advise me on the Pros and Cons.
@BABEENGINEER
@BABEENGINEER 3 жыл бұрын
In MVVM, don't we try to avoid having any instance of Model in the View/View Controller? Shouldn't it be an instance of Model in the View Model, and an instance of View Model on the View/View Controller?
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Yes, you can do it that way too. There a few different flavors of the pattern
@loggioRafa
@loggioRafa 5 ай бұрын
why you compiled first before doing some code? is any reason behind that?
@yashuttekar1640
@yashuttekar1640 9 ай бұрын
Thanks. Your videos really help me. Can you explain mvvm using an api call ?
@cuevas714
@cuevas714 4 жыл бұрын
Thanks ! So the view-model is pretty much just the entire data that will be held/used by a component along with it's custom functions. In bigger apps would a screen with custom components all be separated into their own view-models ?
@iOSAcademy
@iOSAcademy 4 жыл бұрын
Basically, the main takeaway is that viewModels are not equal to models. If a view only shows a small subset of a model's data, that it what it should be. In large projects, yes, each view has its own viewModel and often, a controller has 10+ core views. This pattern really helps separate out backing data and logically group code organization
@cuevas714
@cuevas714 4 жыл бұрын
iOS Academy thanks ! I was reading a book about design patterns and it mentioned MVVM makes the using of bindings in order for the view-model and view to update one another. It’d be great if you could eventually make a video about these bindings and how companies handle bindings. Thanks again for the goldmine of content :)
@redhotbits
@redhotbits 11 ай бұрын
mvvm is massive view viewmodel
@Ravikanth_007
@Ravikanth_007 4 жыл бұрын
Thanks for the video, very well explained.
@iOSAcademy
@iOSAcademy 4 жыл бұрын
You're very welcome
@rondamon4408
@rondamon4408 2 жыл бұрын
Xib is the XML file, the nib is the compiled one, which is the one copied on the application bundle.
@aafaqahmed2265
@aafaqahmed2265 3 жыл бұрын
Amazing stuff very well done!, nice and concise video on MVVM. I really got this easily. One feedback is do zoom but just a little bit zoom so we can know where you are. However you are doing great.
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Thanks for the feedback
@hiteshchouhan4026
@hiteshchouhan4026 3 жыл бұрын
Can we use data Model in viewController while accessing data from viewModel in MVVM pattern ?
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Yes
@DigitalHole
@DigitalHole 4 жыл бұрын
Super smooth explanation.. Keep up the great work 👍
@iOSAcademy
@iOSAcademy 4 жыл бұрын
Thanks! Much appreciated
@67Diadem
@67Diadem 3 жыл бұрын
Hello, great tutorial. A small request kindly please make video without using storyboards, because many companies does not hire ios developer who use storyboards, programmatically is the best way to learn. May be it's hard to learn to code everything like to create tableview or etc, but companies want those candidates who create an app without using storyboards. If you have complete beginner tutorials that creates an ios app then please shar the link. You are a very good teacher and I want to learn from you...
@saleemabbas4275
@saleemabbas4275 2 жыл бұрын
Great way of explanations
@vindajojo
@vindajojo 4 жыл бұрын
Nice video👍(Don't zoom, I can see what you type😄)
@camelectric
@camelectric 3 жыл бұрын
Answering your 10 years old question, in ancient OS X days, nibs where native files. In OS X 5, the changed the format to xml, hence Xib.
@deanolium
@deanolium 3 жыл бұрын
And NIB comes from Nextstep Interface Builder, as OSX and the visual builder parts of Xcode are all based on NextStep.
@ashwina.u2876
@ashwina.u2876 3 жыл бұрын
good one for a beginner. It would be better if you explain MVVM with Combine or RxSwift. Your explanation is simple and make sense. :)
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Thanks
@ConernicusRex
@ConernicusRex 2 жыл бұрын
RxSwift isn't really used at all anymore since Combine came out.
@mutasemwahbeh6954
@mutasemwahbeh6954 3 жыл бұрын
Thank you Afraz!
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Youre welcome
@hareeshgangadhara415
@hareeshgangadhara415 2 жыл бұрын
How to know why we use mvvm over mvc?
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Subjective
@AmitBiswastunebox
@AmitBiswastunebox 4 жыл бұрын
Can you create a video on MVP design pattern too ? Please
@iOSAcademy
@iOSAcademy 4 жыл бұрын
Yep! On my list!
@AmitBiswastunebox
@AmitBiswastunebox 4 жыл бұрын
iOS Academy Thanks a lot ! I am so glad you are doing so well . Incredible stuffs with phenomenal passion and effort
@ishaqhamin
@ishaqhamin 4 жыл бұрын
Really struggling to find a good tutorial on MVVM in Swift and I really struggled with yours. The zooming in and out was horrible, you explain well but you go really fast. I was coding along and got a few errors but cannot see enough of the full screen to see where I go wrong.
@iOSAcademy
@iOSAcademy 4 жыл бұрын
Ill do another one, go slower and zoom less. Thanks for the feedback
@ishaqhamin
@ishaqhamin 4 жыл бұрын
iOS Academy no problem. Seems like you’re on the right path, though!
@priktop8440
@priktop8440 3 жыл бұрын
@@iOSAcademy Did you create this one yet? I would be welcoming it :)
@ConernicusRex
@ConernicusRex 2 жыл бұрын
A lot of the problem with MVC comes from people using vanilla MVC on swift projects instead of MVC-A (The apple model). MVC-A and MVC+S are as good as MVVM in non-reactive architectures.
@talhakhanwhizpool7813
@talhakhanwhizpool7813 4 жыл бұрын
Wrong explanation, where is data binding?
@iOSAcademy
@iOSAcademy 4 жыл бұрын
You don’t necessarily need to use data binding
@MrBrunomalo1
@MrBrunomalo1 3 жыл бұрын
But, yo have to put de datasource in other file, the viewcontroller have to be stupid, only for show data. Your example is so bad.
@ziedagoubi7652
@ziedagoubi7652 Жыл бұрын
this is not an mvm pattern because you missed the most important thing which is the view shouldn't knows about the data it should be dummy as much as possible, so move that data to the viewmodel and create an instance of the viewmodel in the initialiser of the view
@samha1513
@samha1513 Жыл бұрын
Viewmodel should have an instance of the model. VideModel { var model = Model() let firstname:String { Return firstname = self.model.firstname } } Just saying
@semihozsoy982
@semihozsoy982 2 жыл бұрын
I like your videos but this video does not very understandable concept of MVVM. Why I am saying this because MVC to MVVM maybe good way to explain the concept but in my side it just complicate the things which is related the MVVM.
@brilliantaksan
@brilliantaksan 3 жыл бұрын
umm, sorry but is this UIKit? i thought at first this was a swiftui video hahhahah
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Yes, uikit
@eminemini4500
@eminemini4500 4 жыл бұрын
The video is amazing, but constant zooming in and out looses focus. You have to remove that from your videos!
@iOSAcademy
@iOSAcademy 4 жыл бұрын
Thanks for the feedback
@ShahinShamS
@ShahinShamS 4 жыл бұрын
This is no MVVM
@iOSAcademy
@iOSAcademy 4 жыл бұрын
Im going to do a more in depth MVVM video for folks who want more in depth
@nodetransit
@nodetransit 2 жыл бұрын
I did not watch it because it was nauseating. Why not record it in a smaller resolution and stop zooming in and out?
@iOSAcademy
@iOSAcademy 2 жыл бұрын
New videos have no zoom
@Star-rq3jd
@Star-rq3jd 2 жыл бұрын
no zoom plz.
@prahladreddy6839
@prahladreddy6839 2 жыл бұрын
No Zooming, please
@burakturhan9708
@burakturhan9708 Жыл бұрын
I just would like to say please dont zoom frequently and too much it makes hard to keep in fllow
@iOSAcademy
@iOSAcademy Жыл бұрын
New videos have no zoom. Thanks for the feedback
@ReviewGame10
@ReviewGame10 2 ай бұрын
The zooming part is annoying as ....
@learnwith1807
@learnwith1807 4 жыл бұрын
this is not view model full content!!!
@iOSAcademy
@iOSAcademy 4 жыл бұрын
Ill be doing a follow up. Itd be great if you mention what more youd like to see
@yuthegamer1794
@yuthegamer1794 3 жыл бұрын
No offense and thanks for your effort, by the way you communicate, you are a beginner ios dev, and this video demonstrates MVC not mvvm, please stop confusing the new comers.
@30guarino
@30guarino 3 жыл бұрын
He's been at for 10 years....think he has some experience lol
@apintex
@apintex 3 жыл бұрын
horrible with so much zoom
@iOSAcademy
@iOSAcademy 3 жыл бұрын
New videos have no zoom :)
@MrReneArguelles
@MrReneArguelles 3 жыл бұрын
The zooming in and out is just unbearable :(
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Newer videos dont have zooming. Im going to redo this video!
Swift: How to Migrate MVC to MVVM & Intro Unit Testing
33:11
Lets Build That App
Рет қаралды 116 М.
Sigma Kid Hair #funny #sigma #comedy
00:33
CRAZY GREAPA
Рет қаралды 36 МЛН
ВОДА В СОЛО
00:20
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 30 МЛН
What it feels like cleaning up after a toddler.
00:40
Daniel LaBelle
Рет қаралды 79 МЛН
Теория MVVM
10:46
SwiftBook
Рет қаралды 33 М.
Everything You NEED to Know About Client Architecture Patterns
5:51
Swift-уроки: Simple MVVM part1 - TableView
16:59
Сергей Горбачёв / cmd+B, cmd+R
Рет қаралды 3 М.
MVP по SOLID c DI и Unit test на Swift 5 part 1
54:47
The Swift Developers
Рет қаралды 31 М.
How to Become an iOS Developer - The Skills You Need
8:21
CodeWithChris
Рет қаралды 18 М.
How to use the Coordinator pattern in iOS
18:12
Paul Hudson
Рет қаралды 71 М.
How to use Auto Layout for beginners in Swift - iOS 2023
13:49
iOS Academy
Рет қаралды 76 М.
Sigma Kid Hair #funny #sigma #comedy
00:33
CRAZY GREAPA
Рет қаралды 36 МЛН