Post

Replies

Boosts

Views

Activity

Reply to iOS 18 SwiftData ModelContext reset
Found a solution that worked for me. In my case I was fetching data asynchronously using a ModelActor. The fix was I had to refetch the model data again using the modelContext model(for:) method // Async fetch of an episode from a playlist if let episode: Episode = await playlist.episode() { // This was missing and was critical. I needed to refetch the data. let episode: Episode = modelContext.model(for: episode.persistentModelID) as! Episode } There's probably a better way to structure my code to prevent this...but this worked as a fix for me where the other solutions didn't.
Sep ’24