gpt4 book ai didi

swift - NSFetchRequest 找不到实体名称 'Article' 的 NSEntityDescription '

转载 作者:行者123 更新时间:2023-11-28 06:46:33 25 4
gpt4 key购买 nike

我知道其他人以前也问过这个问题。但是我尝试了答案,但他们没有解决问题。

2016-03-23 13:12:41.837 Project[2453:622728] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSFetchRequest could not locate an NSEntityDescription for entity name 'Article''
*** First throw call stack:
(0x182d7ee38 0x1823e3f80 0x184be5824 0x184bfde18 0x1000c4f38 0x1000c4af0 0x1000c47bc 0x1000c2738 0x1000c1790 0x1000c1ac8 0x187ec8b40 0x187ee0fd0 0x18807bd10 0x187f87d28 0x187f87a04 0x187f8796c 0x194581fd0 0x187ec40e4 0x18586aa28 0x185865634 0x1858654f4 0x185864b24 0x18586486c 0x18585ddd8 0x182d347b0 0x182d32554 0x182d32984 0x182c5cd10 0x184544088 0x187f31f70 0x1000d4f00 0x1827fa8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

在 View Controller 中

// MARK: - Core Data Convenience
func saveContext() {
CoreDataStackManager.sharedInstance().saveContext()
}
var sharedContext: NSManagedObjectContext {
return CoreDataStackManager.sharedInstance().managedObjectContext
}
lazy var fetchedResultsController: NSFetchedResultsController = {
let request = NSFetchRequest(entityName: "Article")
request.predicate = NSPredicate(format: "pin == %@", self.annotation)
request.sortDescriptors = [NSSortDescriptor(key: "title", ascending: true)]

let fetched = NSFetchedResultsController(fetchRequest: request, managedObjectContext: self.sharedContext, sectionNameKeyPath: nil, cacheName: nil)
fetched.delegate = self
return fetched
}()

在模型.xcdatamodel

Model.xcdatamodel

Model.xcdatamodel

Link to Article.swift

最佳答案

在类定义上方添加@objc(Article)

@objc(Article)
class Article: NSManagedObject {}

关于swift - NSFetchRequest 找不到实体名称 'Article' 的 NSEntityDescription ',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36188060/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com