Duplicate of 10114310: CoreData ordered relationships: CoreDataGeneratedAccessors crashes on insert

Number:rdar://10114310 Date Originated:13/09/2011
Status:closed Resolved:
Product:iOS SDK Product Version:5.0
Classification:Serious Bug Reproducible:Always

CoreDataGeneratedAccessors for an ordered one-to-many relationship crash at runtime with message

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSSet intersectsSet:]: set argument is not an NSSet'
*** First throw call stack:
(0x16ad022 0x183ecd6 0x1650124 0x96fd3e 0x93ad1a 0x96fbae 0xf920b7 0xbfdc069 0x3dcc 0x16aee99 0x1b14e 0x259a0e 0x16aee99 0x1b14e 0x1b0e6 0xc1ade 0xc1fa7 0xc1266 0x403c0 0x405e6 0x26dc4 0x1a634 0x1597ef5 0x1681195 0x15e5ff2 0x15e48da 0x15e3d84 0x15e3c9b 0x15967d8 0x159688a 0x18626 0x2a4d 0x29b5)

Steps to Reproduce:

Create an ordered relationship and generate the NSManagedObject subclasses, e.g.:

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

@class Event;

@interface Image : NSManagedObject

@property (nonatomic, retain) NSString * path;
@property (nonatomic, retain) Event *event;


Then, try to create an Event object and add an Image object to it:

    NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
    Event *event = [NSEntityDescription insertNewObjectForEntityForName:@"Event" inManagedObjectContext:context];
    // If appropriate, configure the new managed object.
    [event setTimeStamp:[NSDate date]];
    // make an image
    Image *image = [NSEntityDescription insertNewObjectForEntityForName:@"Image" inManagedObjectContext:context];
    image.path = @"/something";
    [event addImagesObject:image];
The app will crash on the last line with aforementioned exception.


It seems it's worked starting from iOS 10

By andrey.ermoshin at June 16, 2017, 7:18 a.m. (reply...)

Still not fixed! After over 4 years.

It's still repro on XCode 6.4 iOS 8.4.

Still not fixed! After over 3 YEARS!

Come on Apple! It really sucks that we can't use ordered one-to-many relationships in CoreData and have to use workarounds!

By ruediger.rill at Sept. 21, 2014, 10:52 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!