zoukankan      html  css  js  c++  java
  • Core Data ,inverse

    Leaving the Inverse field with the value No Inverse Relationship gives you two compiler warnings: consistency error and misconfigured property.

    You can ignore these warnings and run your application without specifying an inverse relationship—after all, these are compiler warnings, not compiler errors—but you could face unexpected consequences. Core Data uses bidirectional relationship information to maintain the consistency of the object graph (hence the Consistency Error) and manage undo and redo information. If you leave a relationship without an inverse, you imply that you will take care of the object graph consistency and undo/redo management. The Apple documentation strongly discourages this, however, especially in the case of a to- many relationship. When you don’t specify an inverse relationship, the managed object at the other end of the relationship isn’t marked as changed when the managed object at this end of the relationship changes. Consider the example of a Player object being deleted and having no inverse relationship back to its team. Any optionality rules or delete rules aren’t enforced when the object graph is saved. 

    stackOverflow:是否一定要inverse,没有inverse,什么情况下会有麻烦

    http://stackoverflow.com/questions/764125/does-every-core-data-relationship-have-to-have-an-inverse

    The League Manager application, for example, sets the Delete Rule for the “players” relationship in the Team entity to Cascade so that deleting a team would delete all the players related to it. If you set that rule to Deny and a team had any players, trying to delete the team would result in an error on any attempts to save the context with the message “team is not valid.” Setting the Delete Rule to Nullify would preserve the players in the persistent store, though they would no longer belong to any team.

    The No Action option represents another way, such as not specifying an inverse relationship, that Core Data allows you to accept responsibility for managing object graph consistency. If you specify this value for the Delete Rule, Core Data allows you to delete the source object but pretends to the destination objects that the source object still exists. For the League Manager application, this would mean disbanding a team but still telling the players to show up for practices and games. You won’t find many compelling reasons to use the No Action setting, except perhaps for performance reasons when you have many destination objects. Chapter 7 discusses performance tuning with Core Data. 

  • 相关阅读:
    几种比较和谐的文字背景颜色搭配
    C#中读取pdm文件信息(PowerDesigner读取方法)(源码共享)
    WinForm应用程序框架设计之WinAction(新增数据)
    iBatis.NET在使用浮点类型时报错
    Vortex2D.NET在ScreenManager前创建节点会出错。
    WinForm应用程序框架设计之WinAction(数据操作)
    WinForm应用程序框架设计之WinAction(一:显示列表窗体)
    WinForm应用程序框架设计之WinAction(介绍)
    点击其他checkbox,然后显示和隐藏区域
    11PX中文字体,清晰
  • 原文地址:https://www.cnblogs.com/zhangjl/p/3630715.html
Copyright © 2011-2022 走看看