SwiftUI Preview issue with @State and CoreData
问题 I'm having trouble getting a preview to work with what seems like a pretty simple struct. Customer is a CoreData entity: struct CustomerDetailView: View { @Environment(\.managedObjectContext) var moc @State var showNewCustomer = false var customer: Customer var body: some View { I've tried almost everything that doesn't work, including this: struct CustomerDetail_Previews: PreviewProvider { static var previews: some View { let context = (UIApplication.shared.delegate as! AppDelegate)