ios - 如何避免核心数据警告 "Entity should have an inverse relationship"?

标签 ios objective-c core-data warnings

我有一个模型图,其中有几个实体与其他实体具有一对多关系。
这意味着反向关系应该是一对多,但那是不可能的。

核心数据运行良好,无反比关系;唯一让我发疯的是警告:

Entity should have an inverse relationship

有人知道如何避免这些特定警告吗?

最佳答案

Inverse Relationships

Most relationships are inherently bi-directional. If a Department has a to-many relationship to the Employees that work in a Department, there is an inverse relationship from an Employee to the Department. The major exception is a fetched property, which represents a weak one-way relationship—there is no relationship from the destination to the source (see “Fetched Properties”).

You should typically model relationships in both directions, and specify the inverse relationships appropriately. Core Data uses this information to ensure the consistency of the object graph if a change is made

引用 Apple documentation

作为一般规则,一对多关系具有多对一逆关系。如果您想定义多对多关系,您只需将一个关系定义为一对多,并将其反向关系也定义为一对多。

关于ios - 如何避免核心数据警告 "Entity should have an inverse relationship"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21642392/

相关文章:

ios - 你如何打印出核心数据对象?

ios - iOS 应用程序会干扰 ipad 键盘吗?

ios - 如何将 iOS 11 控制中心中的屏幕截图转发到您的应用程序?

ios - 选择主 Storyboard或 xib 时 Xcode 6 GM 崩溃

iphone - 我可以在 iOS 的系统键盘上添加一个键吗?

objective-c - 如何随机化 NSMutableArray?

ios - 按 UITextView 上的链接时应用程序崩溃

objective-c - 使用 NSWorkspace 在浏览器中打开多个 URL

iPhone核心数据与Ruby on Rails同步

ios - 将 PonyDebugger 与 Monotouch 一起使用?