如何将 @FetchRequest
与设置了 Codegen: Class Def.
的 CoreData
实体 Post
一起使用在 Xcode
中?所以我不手动创建Post
”实体类,而是让Xcode生成它?
我现在得到一个
Use of undeclared type
Post
作为最后一行的错误。
@FetchRequest(entity: Post.entity(), sortDescriptors: [
NSSortDescriptor(keyPath: \Post.date, ascending: true)
])
var posts: FetchedResults<Post> // Use of undeclared type ´Post´
最佳答案
核心数据有时会出现问题。尝试退出 Xcode 并重新打开它。
关于swift - 带有核心数据的 SwiftUI 中的 @FetchRequest 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58079090/