I've an iPhone applications with 2 models, Category and Content, which have a many-to-many relationship.
This is the code: Content
@interface Content : NSManagedObject {
}
@property(readwrite, retain) NSString *type;
@property(readwrite, retain) NSString *mainText;
...
@property (copy) NSSet * categories;
@end
Category
@interface Category : NSManagedObject {
}
@property (nonatomic, retain) NSNumber * id;
@property (nonatomic, retain) NSNumber * active;
...
@property (copy) NSSet * contents;
@end
And then this operation:
...
NSSet *tmp_set = [NSSet setWithArray:some_array_with_contents objectsAtIndexes:custom_indexes]];
cat.contents = tmp_set;
[[DataModel managedObjectContext] save:&error];
...
On the last line, the app crashes badly saying:
-[__NSCFSet _isValidRelationshipDestination__]: unrecognized selector sent to instance 0x5c3bbc0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFSet _isValidRelationshipDestination__]: unrecognized selector sent to instance 0x5c3bbc0'