SwiftData with MVVM | Does it make sense?

preview_player
Показать описание
Apple showed us how easy SwiftData is to use inside Views. Let's have a look at using it inside ViewModels (with the new Observation framework) as well.

Affiliate Links ❤

If you have any video suggestions please feel free to let me know by a comment.
Get in contact via
Рекомендации по теме
Комментарии
Автор

started watching all of your videos since wwdc 23. ty for not zooming in n out too many times any more!;) good videos!! mvvm appears too complicated here. i ditched mvvm some time ago and only focus on MV pattern with a „storage“/cache. works a lot smoother for me personally :)

Meta
Автор

I came to the same conclusion to not use MVVM after experimenting around too. Now I'm just struggling with the limited documentation, but this stuff is exciting.

Right now I'm having an issue with "illegal attempt to establish relationship 'relationshipNameHere' betweenobjects in different contexts.

I got into this by attempting to assign a model to a property on another model of that type.

Have you run into this issue yet with your experiments with swiftdata?

arukshun
Автор

Great content! Keep the Swift UI tutorials coming. Can you please cover drag and drop, from one table to another. Thanks

dmitrygolovin
Автор

I appreciate these update videos. Thanks Flo! Very helpful. I'd be interested in a video about live updating database subscriptions for this approach. :)

marcelfyi
Автор

I can't believe it, view model now accepts context from the environment! Holy Data!

foilhat
Автор

Hi, is there any way to inject the modelcontext into the viewmodel without using the onAppear?

juanfrancisco
Автор

For Android we use MVVM or MVI with Compose / Kotlin Flow / RoomDB / Hilt DI ... but for Swift / SwiftUI / SwiftData it does not fit ???

SiamakAshrafi
Автор

Thanks for sharing a video its awesome. Can you please make Data Model migration on SwiftData.

sivasankarkanna
Автор

How would Swift Data work in conjunction with CloudKit? I'm bashing my head against the wall trying to figure this one out, and Apple has completely ignored this topic in all the documentation I've read.

DavidM
Автор

Great video! Looks like standard MVVM is even less relevant now. I would suggest making a video on how to integrate SwiftData with something like Firestore.

guyincognito
Автор

I also thought MVVM is not needed for SwiftUI, but if you want to do serious unit testing of your business logic, via injection of mocks, it gets harder without a view model. Also sometimes when working with older API in iOS that use the delegate pattern (that oftentimes dictates NSObject conformance), stuff gets easier.

haselhofler