You can get this error several different ways. If you get it during fetch requests then you should try this:
@FetchRequest(entity: NSEntityDescription.entity(forEntityName: "Your Entity Name", in: managedObjectContext), sortDescriptors: [NSSortDescriptor(key: "Your Key", ascending: true)])
In dynamic fetch requests you should try this:
var entity: Entity
var fetchRequest: FetchRequest<Your Entity>
init(_ entity: Entity) {
self.entity = entity
self.fetchRequest = FetchRequest(entity: NSEntityDescription.entity(forEntityName: "Your Entity", in: managedObjectContext), sortDescriptors: [NSSortDescriptor(key: "Your Key", ascending: true)], predicate: NSPredicate(format: "entity.uniqueIdentifier == %@", entity.uniqueIdentifier!))
}
var youEntities: FetchedResults<Your Entity> {
fetchRequest.wrappedValue
}
When creating core data objects:
let entityDescription = NSEntityDescription.entity(forEntityName: "Your Entity", in: managedObjectContext)
let object = Your Entity(entity: entityDescription!, insertInto: managedObjectContext)
Hope this helps for your Core Data with SwiftUI issues.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags: