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. 

  • 相关阅读:
    get 传 json 数据
    go text/template html/template invalid memory address or nil pointer dereference
    (转)go语言变参,匿名函数的多种用法
    shell 定义变量 坑
    python3 使用aria2下载的一个脚本
    python3 selenium 超时停止加载,并且捕捉异常, 进行下一步【亲测有效】
    selenium学习笔记——driver.get(url) 页面加载时间太长
    python Selenium chromedriver 自动化超时报错:你需要使用多标签保护罩护体
    selenium等待
    小数据池与代码块
  • 原文地址:https://www.cnblogs.com/zhangjl/p/3630715.html
Copyright © 2011-2022 走看看