SwiftUI - Intro to MVVM | Example Refactor | Model View ViewModel

preview_player
Показать описание

In today's video I give you an introduction to the concept of the Model View ViewModel (MVVM) Architecture with SwiftUI. We will refactor a screen into a viewModel as an example. I explain the concept for those who have no idea what MVVM is so I keep it pretty basic. The general idea is to keep your business logic out of your views.This tutorial was created in Xcode 12.5 and Swift 5.4.

Starter Project Download:

If you like my teaching or presentation style, I've started creating my own courses:

Twitter:

Link to my book - How I Became an iOS Developer:

Check out my podcast, iOS Dev Discussions:

Book and learning recommendations that help out the channel if you decide to purchase (Affiliate Links):

Paul Hudson's Hacking With Swift:

Donny Wals - Combine:

Mark Moeyken’s SwiftUI Books:

Learn Advanced Swift Here:

Ray Wenderlich Books:

Ray Wenderlich Videos:

Links to my iOS Dev Setup & iOS Dev Book Recommendations

#swift #softwaredeveloper #iosdeveloper
Рекомендации по теме
Комментарии
Автор

I’ve heard several explanations of MVVM, but thinking of the view as being dumb makes perfect sense to me - I finally get it!

Sperius
Автор

I don't know if you're the best teacher of the world, but your presentations and explanations are so clear that I've enrolled your free lessons for now, and it's so transparent that the way you are teaching is the best way for me to learn. It's complete, it's evolutive... You are my SwiftUI hero now! Many thanks to share your firsts lessons, it's showing how the way you teach is efficient. Please keep the way going on. I'm wishing the best for you! Best regards. Greg

GrégoryV-bs
Автор

This is easily the most helpful video I have seen to explain SWIFTUI MVVM

clayfulgham
Автор

A great video Sean. Thank you for the real-world code example during the explanation. I would very much enjoy seeing more of your architectural explanations.

CodeDropAccount
Автор

Who knew I was passively making a MVVM.

jaylensmith
Автор

Something always felt wrong about putting functions in my view structs 😅 Thanks for this clear explanation! :)

callmetyler
Автор

Would this refactor have been the same if we wanted to go with MVC rather than MVVM? I kinda struggle to find the difference between the two tbh.

Poroto
Автор

This is clean stuff @sean. I can hardly find content that is so clean in iOS. Thanks a lot, please come up with a big how to build video with MVVM pattern. Much love ❤️

hengideguru
Автор

That's exactly what I need, thank you, your videos are always great!

lukasbro
Автор

new bee in iOS, but quickly pick it up based on your videos, thanks a lot, no 1 iOS training online

python_lhu
Автор

You've helped me getting that darn @published / @observableobjec concept to sink in. Thanks!

coolisfoolable
Автор

Great video! Really appreciate the "visual learning" stuff.

Bjorn-EricAbrahamsson
Автор

Could you do a video breaking down Alerts and how you set it up in this video?

justinpelletier
Автор

great example for starter atleast..keep it up..one suggestion instead of calling getAppetizers function in onAppear, call in initializer in view model class

NishantNarola
Автор

Thanks brother, it was simple and super crisp.

ankitsoni
Автор

A great example to aid in learning this model. Thanks for sharing!

braydoncoyer
Автор

Curious why the use of @stateobject in the view instead of @observedobject?

sabarahuja
Автор

Great video! Is it common to actually put the model in a separate file on its own? So that you have a more lcear 3 part division of the MVVM?

co
Автор

How does this compare to the MVC? Model-view-controller? It seems to me that your 'viewmodel' is doing the same thing a controller would in an MVC.

nadnerb
Автор

I am still catching up, so I have a lot of gaps in my knowledge and understanding of Swift, SwiftUI, SwiftData, etc. Your videos have been very helpful so far. The pace and focus of your videos are perfect. For this one, though, I am wondering how the advent of SwiftData changes the MVVM. Can you pull SwiftData context model into an Observable class model, or does SwiftData break the MVVM?

PhilipJMayo