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

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 พ.ย. 2024

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

  • @multitudes389
    @multitudes389 4 ปีที่แล้ว +85

    without zooming in and out all the time would be easier to follow. getting dizzy here 😀

    • @iOSAcademy
      @iOSAcademy  4 ปีที่แล้ว +6

      Haha thanks for the feedback. Newer vids have less zooming :)

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

      @@iOSAcademy Dont do it we dont want the zoom thing please

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

      @@rishilund4120 No. Nobody does. Stop.

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

      wacky zooming is making me see-sick. ugh

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

    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.

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

    I love how you sum things up in a video shorter than 20 minutes. Keep on doing the good work please

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

    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 2 ปีที่แล้ว +1

      Agreed. The zoom on this one was a little too much. Hard to pause and copy what was being done if following along.

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

    why you compiled first before doing some code? is any reason behind that?

  • @xchen430
    @xchen430 3 ปีที่แล้ว +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?

  • @BABEENGINEER
    @BABEENGINEER 4 ปีที่แล้ว +5

    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  4 ปีที่แล้ว +1

      Yes, you can do it that way too. There a few different flavors of the pattern

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

    Thanks. Your videos really help me. Can you explain mvvm using an api call ?

  • @hustlas4ever
    @hustlas4ever 4 ปีที่แล้ว +6

    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 ปีที่แล้ว +2

      Youre welcome! And you aren't demanding at all! I love getting suggestions :) Glad you like to help

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

    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,?

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

    Thanks for the video, very well explained.

    • @iOSAcademy
      @iOSAcademy  4 ปีที่แล้ว

      You're very welcome

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

    Hi! Thank you for the tutorial! I was wondering, how does the viewModel you introduced make the ViewController less massive? Thank you :)

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

    Xib is the XML file, the nib is the compiled one, which is the one copied on the application bundle.

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

    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 ปีที่แล้ว +16

      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 :)

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

    Great way of explanations

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

    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

  • @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.

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

    Can we use data Model in viewController while accessing data from viewModel in MVVM pattern ?

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

    Thank you Afraz!

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

    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...

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

    Viewmodel should have an instance of the model.
    VideModel {
    var model = Model()
    let firstname:String {
    Return firstname = self.model.firstname
    }
    }
    Just saying

  • @camelectric
    @camelectric 4 ปีที่แล้ว +2

    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 4 ปีที่แล้ว

      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 ปีที่แล้ว +1

    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.

  • @cuevas714
    @cuevas714 4 ปีที่แล้ว +2

    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 ปีที่แล้ว +1

      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 ปีที่แล้ว +1

      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 :)

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

    Super smooth explanation.. Keep up the great work 👍

    • @iOSAcademy
      @iOSAcademy  4 ปีที่แล้ว

      Thanks! Much appreciated

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

    How to know why we use mvvm over mvc?

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

    Where do we write the business logic in mvvm? In some articles it says Model and in some other articles it says Viewmodel.

  • @vindajojo
    @vindajojo 4 ปีที่แล้ว +2

    Nice video👍(Don't zoom, I can see what you type😄)

  • @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

  • @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.

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

    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 ปีที่แล้ว +2

      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 ปีที่แล้ว +1

      @@iOSAcademy Did you create this one yet? I would be welcoming it :)

  • @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.

  • @AmitBiswastunebox
    @AmitBiswastunebox 4 ปีที่แล้ว

    Can you create a video on MVP design pattern too ? Please

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

      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

  • @eminemini4500
    @eminemini4500 4 ปีที่แล้ว +6

    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

  • @talhakhanwhizpool7813
    @talhakhanwhizpool7813 4 ปีที่แล้ว +7

    Wrong explanation, where is data binding?

    • @iOSAcademy
      @iOSAcademy  4 ปีที่แล้ว

      You don’t necessarily need to use data binding

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

      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.

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

    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.

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

    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

  • @ShahinShamS
    @ShahinShamS 4 ปีที่แล้ว +12

    This is no MVVM

    • @iOSAcademy
      @iOSAcademy  4 ปีที่แล้ว +6

      Im going to do a more in depth MVVM video for folks who want more in depth

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

    umm, sorry but is this UIKit? i thought at first this was a swiftui video hahhahah

  • @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

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

    No Zooming, please

  • @Star-rq3jd
    @Star-rq3jd 2 ปีที่แล้ว

    no zoom plz.

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

    The zooming part is annoying as ....

  • @JavierWarren-q8d
    @JavierWarren-q8d 3 หลายเดือนก่อน

    Thompson Margaret White Anthony Johnson Daniel

  • @yuthegamer1794
    @yuthegamer1794 4 ปีที่แล้ว +2

    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 4 ปีที่แล้ว +1

      He's been at for 10 years....think he has some experience lol

  • @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

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

    horrible with so much zoom

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

      New videos have no zoom :)

  • @MrReneArguelles
    @MrReneArguelles 4 ปีที่แล้ว

    The zooming in and out is just unbearable :(

    • @iOSAcademy
      @iOSAcademy  4 ปีที่แล้ว

      Newer videos dont have zooming. Im going to redo this video!