From the course: Complete Guide to SwiftUI

Unlock this course with a free trial

Join today to access over 24,600 courses taught by industry experts.

MVC vs. MVVM

MVC vs. MVVM

- [Instructor] If you've worked with UI Kit and Xcode, you're familiar with the MVC pattern. If you're not, let me explain. UI Kit and much of mobile device programming uses the MVC pattern to organize your code into three functions. The Model is the code that handles your data. The View shows and accepts inputs from the user. The Controller handles the interactions between the two and where you as a developer do most of the front end work. UI kit tends to combine the View and Controller portion into a View Controller class where you either write the View programmatically or use a storyboard. For simplicity, I'm going to take them apart into a simple toggle button example. The button would be the View, and we'd have some Boolean value, which we'd use as our model. The Controller would be some code between the two that when a button is pressed would change the value and the color of the button. In Swift UI we use a variation of MVVM where there's no Controller, just Models and Views…

Contents