Learn Courses My Dashboard

Core Data observable object?

Hello -
I am working on a Core Data app with two related entities that has a tabview. The first entity is in a list on the first tab with a detail view that I can edit.
The second entity is shown on a list in the second tab, and the list label contains the image from the related entity. There is also a detail view for the second entity.

If I edit the image of the first entity, it is not updated on the second tab (but it did on the second entity detail view).

Here is the tab that isn’t updating when CoreData is saved on a different tab:

struct CrossListView: View {
    
    @Environment(\.managedObjectContext) var moc
    @FetchRequest(sortDescriptors: [
        SortDescriptor(\.name)
    ]) var dahlias: FetchedResults<Dahlia>
    
    @FetchRequest(sortDescriptors: [
        SortDescriptor(\.name)
    ], predicate: NSPredicate(format: "name == %@", "Open Pollination")) var openPollination: FetchedResults<Dahlia>
    
    @State public var seedParent: Dahlia?
    @State public var pollenParent: Dahlia?
    
    @FetchRequest(sortDescriptors: [
        SortDescriptor(\.yearCollected)
    ]) var crosses: FetchedResults<Cross>
    
    @State private var showingAddCrossScreen = false
    
    var body: some View {
        NavigationView{
            VStack{ 
                    List{
                        ForEach(crosses) {cross in
                            NavigationLink {
                                CrossDetailView(cross:cross, seedlings: cross.seedlingsArray, seedParent: cross.seedParent, pollenParent: cross.pollenParent)
                            } label: {
                                
                                HStack(spacing:20){
                                    VStack(alignment:.leading) {
                                        let image = UIImage(data: cross.seedParent.image ?? Data()) ?? UIImage()
                                        Image(uiImage: image)
                                          
                                        Text("\(cross.seedParent.wrappedName)")
                                    }
                                    VStack(alignment:.trailing) {
                                        let image = UIImage(data: cross.pollenParent.image ?? Data()) ?? UIImage()
                                        Image(uiImage: image)
                                        
                                        Text("\(cross.pollenParent.wrappedName)")
                                          
                                    }
                                }.frame(alignment: .center)
                            }
                        }
                        
                    }
                }

            }

Googling has said to make something an observable object, but if I make seedParent or pollenParent an @ObservableObject I get the error “Generic struct ‘ObservedObject’ requires that ‘Dahlia?’ conform to ‘ObservableObject’”

If I try making my Entity an ObservableObject, I get the error “Redundant conformance of ‘Dahlia’ to protocol ‘ObservableObject’”

import CoreData

@objc(Dahlia)
public class Dahlia: NSManagedObject, ObservableObject {

}```