I'm trying to create an CoreData Entity observer:
@FetchRequest(sortDescriptors: []) var todoResult: FetchedResults<Todo>
init() {
todoResult.publisher.sink { _ in
print("sink")
} receiveValue: { todos in
print("recoved todos")
}.store(in: &cancellables)
}
But I'm getting this error:
Accessing StateObject's object without being installed on a View. This will create a new instance each time.
Any of you knows why I'm getting this error since I'm not creating this instance in a model? or if you know a work around this error. I'll really appreciated.

CoreData Entitywhich is already anObservableObject? That is the root of your error message.ObservableObjects, just wrap eachTodoin@ObservedObjectin the SwiftUIViewthat needs/makes the changes. BTW it looks like you are trying to use@FetchRequestin a class` useNSFetchRequestorNSFetchedResultsController.