Core data 仅限iOS 8上的核心数据提取崩溃
我在一个项目中使用核心数据,它在iOS 8上的fetch上会中断,但在任何其他iOS版本上都不会。我得到的错误是:Core data 仅限iOS 8上的核心数据提取崩溃,core-data,ios8,swift3,Core Data,Ios8,Swift3,我在一个项目中使用核心数据,它在iOS 8上的fetch上会中断,但在任何其他iOS版本上都不会。我得到的错误是: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath myId not found in entity <NSSQLEntity Entity id=1>' 它在do-语句中中断,不会抛出错误。在iOS 9.0+上,它也不会抛出任何错误。
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath myId not found in entity <NSSQLEntity Entity id=1>'
它在
do
-语句中中断,不会抛出错误。在iOS 9.0+上,它也不会抛出任何错误。代码是用Swift 3编写的。请显示包含谓词、entityName aso的调用。谢谢,您为我指明了正确的方向。在iOS 9+上,我的entityName是正确的,在iOS欢迎。如果你发布代码,也许有人能告诉我原因。请显示包含谓词、entityName aso的调用。谢谢,你为我指明了正确的方向。在iOS 9+上,我的entityName是正确的,在iOS欢迎。如果你发布代码,也许有人能告诉你原因。
static func fetch(_ sortDescriptors: [NSSortDescriptor]?, predicate: NSPredicate?, entityName: String) -> [NSManagedObject] {
let managedObjectContext = (UIApplication.shared.delegate as! AppDelegate).managedObjectContext
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: entityName)
fetchRequest.sortDescriptors = sortDescriptors
fetchRequest.predicate = predicate
var fetchedObjects = [NSManagedObject]()
do {
fetchedObjects = try managedObjectContext.fetch(fetchRequest) as! [NSManagedObject]
} catch {
log.error("error")
}
return fetchedObjects
}