Building Robust ViewModels

Feb 28 2025 · Swift 5.9, iOS 17, Xcode 15.3

Lesson 03: Data Binding Techniques

Demo 2

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Continue with your project from the first demo or open the TheMet app in the Final demo 1 folder. Now, it’s time to implement your favorite feature in ObjectView.

@Binding var object: Object
object.isFavorite.toggle()
return ObjectView(object: $object)
@Bindable var twoWayStore = store
List($twoWayStore.objects) { $object in
ObjectView(object: $object)
      ContentView(store: store)
//      ContentView()
//        .environment(store)
  var store: TheMetStore
//  @Environment(TheMetStore.self) var store
@Bindable var store: TheMetStore
  ContentView(store: TheMetStore())
//  ContentView()
//    .environment(TheMetStore())
        List($store.objects) { $object in
//        List($twoWayStore.objects) { $object in
struct TheMetApp: App {
//  @State var store = TheMetStore()

  var body: some Scene {
    WindowGroup {
//      ContentView(store: store)
      ContentView()
//        .environment(store)
    }
  }
}
  @State var store = TheMetStore()
//  @Bindable var store: TheMetStore
See forum comments
Cinema mode Download course materials from Github
Previous: Instruction Next: Conclusion