Hello,
When using Core Data, is there a way to create a static instance of an entity, for default values.
There are cases in which I feel the need to pass optional instances of an entity to a new view, which need to be unwrapped. This need arises especially when working with the new NavigationSplitView, because I need to pass an instance of an element to the detail view.
In NavigationSplitView, for navigation to the detail view, as far as I understand, one needs to create a @State variable for the selected instance of an object, and the type of this @State variable is an optional that needs unwrapping. I'd like to make the @State variable to be the type of the core data element.
In Content View:
@State selectedPersonEntity: PersonEntity?
Note: Where Person is the Core Data entity.
If not declared optional, the App file will ask you pass a default instance of Person. This is what I want created as some sort of Static value.
When passing to the Detail View, I can pass selectedPerson to a variable of type Person.
Thus far, I've managed to work with passing the Attributes of Person, and unwrapping them individually. But for entities with lots of attributes, it is quite tiresome to pass a dozen of attributes to a new view.
Any help would be appreciated! Thanks!