Posts

Post not yet marked as solved
6 Replies
2.3k Views
I'm trying to load items from the database into a list, it works fine on device and simulator but Preview will always crash with the following message: " Cannot preview in this file — Connection interrupted: send message to agent" Here's my code struct SettingsView: View {     @Environment(\.managedObjectContext) var moc     @FetchRequest(entity: ChildProfile.entity(), sortDescriptors: []) var children: FetchedResults<ChildProfile>          var body: some View {         VStack {             List {                 Section(header: Text("Children")) {                     ForEach(children, id: \.id) { child in                         ChildRow(child: child)                     }                 }             }         }     } } struct SettingsView_Previews: PreviewProvider {     static let moc = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)          static var previews: some View {         let defaultChild = ChildProfile(context: moc)         defaultChild.id = UUID()         defaultChild.name = "Lex"         return SettingsView().environment(\.managedObjectContext, moc)     } } Previewing ChildRow with the same preview code works fine in the canvas Is this a bug in Xcode or am I missing something?
Posted
by Bwgan.
Last updated
.