Post

Replies

Boosts

Views

Activity

Reply to SwiftData: Is syncing changes across ModelContext’s working in Beta 1?
I am saving after making these changes. In the case of a batch(?) update in the main modelContext... let _ = try? context.update(expressions: ["isRead": NSExpression(forConstantValue: true)], model: Article.self, where: predicate) try? context.save() and in the case of a background thread with a new ModelContext... let context = ModelContext(container) context.autosaveEnabled = true let article = Article(…) context.insert(article) try? context.save() The changes are definitely getting saved to the DB. If I force refresh my View and its @Query, the new Articles appear. In both cases, I also don't see didSave get called... .onReceive(NotificationCenter.default.publisher(for: ModelContext.didSave)) { notification in print("😀 \(#function) didSave") }
Jun ’23