SwiftUI Preview has error "A fetch request must have an entity"

2020-12-29 17:11:41 SwiftUI

Change

struct SheetMusicView_Previews: PreviewProvider {
    static var previews: some View {        
        SheetMusicView()
            .environment(\.managedObjectContext, PersistenceController.shared.container.viewContext)
    }
}

1
2
3
4
5
6
7

To

struct SheetMusicView_Previews: PreviewProvider {
    static var previews: some View {
        let context = PersistenceController.shared.container.viewContext
        return SheetMusicView()
            .environment(\.managedObjectContext, context)
    }
}
1
2
3
4
5
6
7
Powered By Valine
v1.5.2