1

I have a a one-to-many relationship as an NSOrderedSet on an NSManagedObject.

When the addObject: method is called on the ordered set (which I'm calling from a property on an NSManagedObjectModel subclass object), however, the inverse relationship is not being set automatically. What can cause this?

As a related note, I am using Magical Record to make it easier to map data to the NSManagedObject objects.

Further, I've also referred to this post, but I'm not overriding these methods on my subclass:

Core Data Inverse Relationship Not Being Set

Community
  • 1
  • 1
JRG-Developer
  • 12,454
  • 8
  • 55
  • 81
  • 1
    We have no code, no model, nothing to go on. I'm use to setting the 'parent' property on my objects and getting the reverse happen automatically. What I suggest you do is take some code where you have the object and its parent, log the parent's NSSet property and the objects parent, set the parent, log it (to make sure it "took"), then relog the parent's set. This is just such a common usage of Core Data it just makes me think your model if foobared. – David H Sep 14 '12 at 20:23
  • Yes, I agree that inverse relationships are a common usage of Core Data. Apparently, however, ordered relationships in Core Data (introduced in iOS 5.0) aren't commonly used or weren't tested well... buggy as heck... here's another stack overflow that addresses this (found after digging): http://stackoverflow.com/questions/7385439/exception-thrown-in-nsorderedset-generated-accessors/7922993#7922993. I'll add an answer to this question for future users with all the findings on why an inverse relationship may not be set automatically (which was the **generic** question asked). – JRG-Developer Sep 14 '12 at 20:35

1 Answers1

1

NSOrderedSet has serious bugs in Core Data. See this post on ways to get around them for the time being:

Exception thrown in NSOrderedSet generated accessors

Community
  • 1
  • 1
JRG-Developer
  • 12,454
  • 8
  • 55
  • 81