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?
Post
Replies
Boosts
Views
Activity
I'm trying to migrate my independent watchOS app from "WatchKit Extension" to be single target watch app, however Xcode 14 will always crash .
I go to Editor > Validate Settings
Click "Perform Changes" and accept the default settings
Xcode immediately crashes
Crash Log
I've tried on the Xcode 14.1. beta and I get the same result.
It's a pretty simple app with no other frameworks or dependancies. Am I doing anything wrong here?
Hi
As title, when trying to use NSFetchedResultsController I get the following error:
'>' is not a postfix unary operator
class WindowController: NSObject, ObservableObject {
@Published var spans: [Span] = []
private let controller = NSFetchedResultsController<Windows>
init(context: NSManagedObjectContext) {
controller = NSFetchedResultsController(fetchRequest: Windows.fetchRequest(), managedObjectContext: context, sectionNameKeyPath: nil, cacheName: nil)
}
}
I can get it to work by changing it to
private var controller = NSFetchedResultsController<Windows>()
but I'm wondering what's going on with the original code.