swift - 带有核心数据的 SwiftUI 中的 @FetchRequest 注释

标签 swift xcode core-data swiftui

如何将 @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´

xcdatamodel

最佳答案

核心数据有时会出现问题。尝试退出 Xcode 并重新打开它。

关于swift - 带有核心数据的 SwiftUI 中的 @FetchRequest 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58079090/

相关文章:

ios - 在 swift3 中看到 UILocalNotification 后如何取消或删除?

ios - 什么是 Sqlite3,我们可以在 coredata 中使用它吗

ios - 如何在 Swift 中更新核心数据中的任何属性?

ios - 可将图像拖动到另一个图像 IOS Swift

swift - SKAction.runBlock 错误

ios - 代码 'Info.plist path not found.'

xcode - XCode 7崩溃报告。我该怎么读? UIKit:forwardTouchMethod

ios - 如何使用 coreData ,swift 将项目添加到各自的父类别

ios - Swift:找不到协议(protocol)声明

ios - 在 Tableview 中,我想知道如何在单元格最后位置设置多行 UILabel