The @FetchRequest works in a view struct. However, in a separate class file, this does not work in a class method. Is there any way to retrieve the data from core data inside a class or a struct that is not a view?
You can manually build an
NSFetchRequest or use an
NSFetchedResultsController. Probably the best thing to do is to use the latter as the data source in an
ObservableObject. There are quite a number of tutorials on how to do that across the web.