[NSSet intersectsSet:]: set argument is not an NSSet

I get this crash, when adding an object to its parent and the relationship was configured to be "ordered".


I googled around, saw various suggested workarounds, some date back all the way to 2011. Anyway I can get the generated property to be an ordered set, or do I have to override all these manually?

Accepted Reply

Not sure if this will help or not, but, I have experienced something similar with "Ordered" relationships within Core Data. Here is what I ended up doing.


- (void)addReportQueriesObject:(ReportQuery *)value {
    NSMutableOrderedSet* tempSet = [NSMutableOrderedSet orderedSetWithOrderedSet:self.reportQueries];
    [tempSet addObject:value];
    self.reportQueries = tempSet;
}


basically I have to initialize a new ordered set, add my new value to that newly allocated ordered set, THEN save that into my ManagedObject. Hope this helps!

Replies

Hmm... this workaround is working (for now)...override the generated 'add' method and do this:


-(void)addNewMarkerObject:(MarkerObject *)marker
{
   //Avoid crash by adding the object this way.
    marker.parent = self;
}


Haven't tried the methods Core Data generates for reordering, ect...hope they work...


Anyone know if this was a regression? Five year old bug, seems like a pretty long time.

Not sure if this will help or not, but, I have experienced something similar with "Ordered" relationships within Core Data. Here is what I ended up doing.


- (void)addReportQueriesObject:(ReportQuery *)value {
    NSMutableOrderedSet* tempSet = [NSMutableOrderedSet orderedSetWithOrderedSet:self.reportQueries];
    [tempSet addObject:value];
    self.reportQueries = tempSet;
}


basically I have to initialize a new ordered set, add my new value to that newly allocated ordered set, THEN save that into my ManagedObject. Hope this helps!

I saw that as one of the other suggessted workarounds. Not sure which workaround is better. I'm leaning more toward adding the object the way I have it now, instead of copying the entire set (though I don't know what Core Data is doing under the covers, so it really may not be anymore effecient).

Err, the other methods also cause crashes...pretty disappointing bug.


It looks like your workaround may the better way to handle this problem...I'm using it in a override of the method that adds multiple objects.

This is no longer working