So I'm trying to setup CoreData with SwiftUI and both the CoreData model and SwiftUI views are working. All I need to do is connect them. I am able to pass a discrete number of BindableObjects but what I need is to pass an array. Here's the setup:
let peristence = PersistenceManager()
var model = [Entry]() // Entry Conforms to NSManagedObject and BindableObject
let request = Entry.createFetchRequest()
let sort = NSSortDescriptor(key: "callsign", ascending: true)
request.sortDescriptors = [sort]
do {
model = try peristence.persistenceContainer.viewContext.fetch(request)
} catch {
fatalError(error.localizedDescription)
}
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: ContentView().environmentObject(model))
Which produces the following error:
Instance method 'environmentObject' requires that '[Entry]' conform to 'BindableObject'
How would I make [Entry] conformant?