1

I am getting following three warning when I compile my core data project

I am not setting an inverse since any change to file Object does not effect the photo Object.And I don't even need to access photo object from the file object

 Misconfigured Property:
 Photos.file should have an inverse

 Consistency error:
 Photos.file does not have an inverse; this is an advanced setting (no object can be in multiple destinations for a specific relationship)

I am setting no action since any change to Factilities Object does not effect the ParentGroup Object.But I need to access ParentGroup object from the Factilities object

Consistency error: 
Setting the No Action Delete Rule on Facilities.parentGroup is an advanced setting

Do I get rid of them or is it ok to to have these warning ?

ila
  • 920
  • 12
  • 35
  • 2
    Why don't you define inverse relationships and set the delete rule to "Nullify"? That ensures to keep the object graph consistent, and does not delete related object (as "Cascade" would do). The overhead is minimal and the warnings are gone :-) – Martin R Mar 31 '13 at 20:07

2 Answers2

8

If you don't need to model an inverse relationship is ok. Warnings are not errors. They are just saying that you are responsible for extra stuff as highlighted in Apple doc (in bold key parts).

It is not strictly necessary to model a relationship in both directions. In some cases it may be useful not to, for example when a to-many relationship may have a very large number of destination objects and you are rarely likely to traverse the relationship (you may want to ensure that you do not unnecessarily fault in a large number of objects at the destination of a relationship). Not modeling a relationship in both directions, however, imposes on you a great number of responsibilities, to ensure the consistency of the object graph, for change tracking, and for undo management. For this reason, the practice is strongly discouraged. It typically only makes sense to model a to-one relationship in one direction.

Anyway, I think you should also be able to fix the warning following this discussion: How to disable no inverse relationship warning for CoreData in Xcode 4.2?.

Hope that helps.

Community
  • 1
  • 1
Lorenzo B
  • 33,216
  • 24
  • 116
  • 190
  • 1
    Is there a similar option to suppress the "Setting the No Action Delete Rule ..." warning? – Martin R Mar 31 '13 at 19:57
  • @MartinR I think there is no option for this but I performed I quick search on the argument. Did you find something? – Lorenzo B Mar 31 '13 at 20:02
  • @MartinR Anyway I think those type of warnings should stay there (remain visible). Just for remember possible sources of bugs. What do you think about? ;-) – Lorenzo B Mar 31 '13 at 20:06
  • 1) No, I did not find anything. I don't even know where `MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS` is documented officially. - 2) I would just define the inverse relationships (see my comment to the question). – Martin R Mar 31 '13 at 20:10
  • @MartinR Yes. **I perfectly agree with your comment.** But he said that he does not want to have an inverse... – Lorenzo B Mar 31 '13 at 20:13
0

Misconigured property can be handled by setting an inverse relationship. It just that I never use that inverse relationship. Or it can be handled as flexaddict explained.

I ended up doing the following for NO action

I set NO ACTION to nullify . I had this concept incorrect. Nullify means that it will remove the source object from the inverse relationship coming from the destination object. It does not mean the it will delete the destination object all together.

ila
  • 920
  • 12
  • 35