Learn how to read and write data with Realm Database for SwiftUI. Realm is a powerful solution to persist data on you iOS device ⭐️⭐️⭐️. We will build an example project in SwiftUI with realm. We will see how the drawing engine of SwiftUI works with objectWillChange, which is a Combine publisher: PassthroughSubject.
The project implements MVVM as a design pattern. You will learn how to create a simple model with realm and relationships between objects. How to create, delete and update objects in realm.
Because realm is based on life objects, it is not working properly with SwiftUI. I will show you situations that will crash your app 💣 and how to prevent them with frozen objects. We will also leverage the Combine that is build inside SwiftUI.
overview:
0:00 intro
3:16 model definition in realm
11:24 view model realm, fetching objects
18:47 SwiftUI list
24:40 data flow in SwiftUI with objectWillChange and realm observe
30:05 deleting objects without crashing
34:54 updating objects that are frozen
48:31 updating objects with a custom Binding
52:51 KVO publisher in Combine
get the final project from my website here: https://www.swiftyplace.com/f/master-...
📔 More information about mongoDB realm:
quick start with SwiftUI and Combine example code: https://docs.mongodb.com/realm/ios/sw...
tutorial from realm with authentication https://developer.mongodb.com/how-to/...
realm documentation with model property cheatsheet (deprecated legacy project) https://docs.mongodb.com/realm-legacy...
new MongoDB realm documentation for iOS https://docs.mongodb.com/realm/sdk/ios/
getting started tutorial with realm https://docs.mongodb.com/realm/get-st...
example for building a mobile chat app using realm https://developer.mongodb.com/how-to/...
If you want to have a refresher on Model-View Model -View, you can check my other video here:
• How to use MVVM in iOS - State Management ...
If you liked what you learned and you want to see more, check out one of my courses!
👨💻 my SwiftUI course https://school.swiftyplace.com/course...
👨💻 my Core Data and SwiftUI course https://school.swiftyplace.com/course...
👩🏻💻 Combine course https://school.swiftyplace.com/course...
#Realm #iOS #Database