PLEASE NOTE: This is not the same question as this question , as I already know that this is due to an Apple bug. Keep in mind that overriding certain methods (e.g. -addFriendsObject: if I had a relationship with friends) is not an option, since I need to do this in a category so that it works for any managed object and regardless of model modification and rebuilding auto-generated classes are generated from it.
The need for this stems from the fact that, apparently, at the moment when ordered relationships and many (NSMutableOrderedSets) dynamic Core Data methods go to hell:
- methods
-add<Relationship>Object , -add<Relationship> , -remove<Relationship>Object and -remove<Relationship> will be broken with the same exception 'NSInvalidArgumentException', reason: '*** -[NSSet intersectsSet:]: set argument is not an NSSet' - the methods in the
insertObject:in<Relationship>AtIndex: instead insertObject:in<Relationship>AtIndex: because the Core implementation for them has not actually been implemented.
As for 2 , I wrote a category that overrides -methodSignatureForSelector: and -forwardInvocation instead, to do something like mutableOrderedSetValueForKey for the name of the relationship, followed by the actual addition or deletion.
Now for 1, the problem is that CoreData actually provides implementations for these methods (although they are not the correct implementations for ordered sets). So I need a way to intercept these selectors, so I can implement the behavior on mutableOrderedSetValueForKey.
Any ideas how to do this?
source share