Post

Replies

Boosts

Views

Activity

Reply to SwiftData Update Item View from Background Thread
Quick question, are you on iOS 18? Did it work in iOS 17? I'm trying to figure out a similar issue that worked in iOS 17, but doesn't work in iOS 18 Beta 1 and Beta 2 (just updated today). In a nutshell I have a parent and child view as part of a NavigationSplitView. A parent view has a @Query for items, the item is passed to the child view, like in your case. In the child there is a method that performs an async task, which updates the item in the background using @ModelActor This update was immediately refrelcted in the child view on iOS 17 but is not reflected in iOS 18. Only if I navigate to parent view and then re-open child I can see the changes.
Jun ’24
Reply to Enabling undo with multi-model schema
Trying to figure out if this is possible for a sharedModelContainer. When creating a new empty multiplatform app with SwiftData, this code is automatically generated in the App.swift: import SwiftUI import SwiftData @main struct SwiftDataTestApp: App { var sharedModelContainer: ModelContainer = { let schema = Schema([ Item.self, ]) let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) do { return try ModelContainer(for: schema, configurations: [modelConfiguration]) } catch { fatalError("Could not create ModelContainer: \(error)") } }() var body: some Scene { WindowGroup { ContentView() } .modelContainer(sharedModelContainer) } } Is there a way to set isUndoEnabled in this scenario? Doesn't look like ModelContainer(for: Schema...) supports it?
Dec ’23