Im finding it impossible to use core data with SwiftUI, because as I pass a core data to a view observed object variable, the navigation link view will hold a reference to the o
After some research online, it's clear to me that this crash can be caused by many things related to optionals. For me, I realized that declaring a non-optional Core Data attribute as an optional in the NSManagedObject
subclass was causing the issue.
Specifically, I have a UUID attribute id
in Core Data that cannot have a default value, but is not optional. In my subclass, I declared @NSManaged public var id: UUID
. Changing this to @NSManaged public var id: UUID?
fixed the problem immediately.