I’m practicing with creating a multiplatform App (could just as well be an iOS app) using the boilerplate code generated by Xcode when Core Data and CloudKit check boxes are selected upon project creation. Xcode generates a persistence.swift file with the Core Data stack code and uses the @FetchRequest property wrapper in the ContentView.swift file. However, I’d like to move some of the more “view model” or non-UI boilerplate code out of ContentView and into a more MVVM-like view model class file so that I keep the ContentView focused on my UI. I would like to continue using the provided persistence.swift file as my Core Data manager content.
Can I still use the power of @FetchRequest in the ContentView (I think it has to remain in my content view), while moving the other boilerplate code Xcode generated out of ContentView to a new view model class file? For example, I’m talking about the automatically generated code for addItem() and deleteItem().
In other words, can I use both the @FetchRequest approach for accessing my entity model while also making my code fit a more MVVM architecture?