Post

Replies

Boosts

Views

Activity

Reply to SwiftData ModelContext.insert crashes, why?
Thanks for the explanation guys. The reason for the test was that I had similar code in my application. I create the ModelContainer in my App and set it on my DataManager, but it would be nil when trying to use it. It was tricky to find the issue.
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Aug ’25
Reply to SwiftData ModelContext.insert crashes, why?
Answering my own question. Found this blog, searching for answers https://blog.jacobstechtavern.com/p/swiftdata-outside-swiftui Thanks Jacob. The answer is simple, but maybe someone can explain. modelContext = container.mainContext works if it's modelContext = ModelContext(container) Done!
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Aug ’25