Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Ordered Sets Data Import and KVC Issues #440

Conversation

JRG-Developer
Copy link
Contributor

Building on @cheneveld 's solution to fix data import for ordered sets, this code invokes the appropriate access and change notifications on self, which is required for Core Data to correctly set the inverse relationship on the related object

…s, this code invokes the appropriate access and change notifications on self, which is required for Core Data to correctly set the inverse relationship on the related object
@sxua
Copy link

sxua commented Mar 29, 2013

👍 Did the same just right now.

{
MRLog(@"Adding object for relationship failed: %@\n", relationshipInfo);
MRLog(@"relatedObject.entity %@", [relatedObject entity]);
MRLog(@"relationshipInfo.destinationEntity %@", [relationshipInfo destinationEntity]);
MRLog(@"Add Relationship Selector: %@", addRelatedObjectToSetMessage);
MRLog(@"Add Relationship Selector: %@", addRelatedObjectToSetMessage);
MRLog(@"perform selector error: %@", exception);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is incorrect. We have no exception variable anymore.

@getchare
Copy link

Hi,
I have exactly the same problem while importing a one-toMany relationship, with a crash due to an NSInvalidArgumentException (the new selector with the "Set" causes an unrecognized selector).

I've tried your patch and it solved my problem. I was wondering why it wasn't merged in MR, I'm currently using version 2.2 (from CocoaPods), but also the current developer branch has no trace of your patch. Why did you close this issue? Did you find an alternative solution? Thank you.

@JRG-Developer
Copy link
Contributor Author

@Charex

I don't remember why I closed this exactly... it may be because there are several competing pulls pending? Or it didn't match up with the latest dev branch...?

Either way, I don't think this pull request has any chance of ever being pulled into the main repo. Mainly because

  1. it's an Apple bug;
  2. it lacks unit tests (I've just started writing unit tests for my own code and didn't here);
  3. yet most importantly, MagicalRecord's authors use mogenerator. Mogenerator's current master branch has something of a fix for this already -- it creates NSMutableSet and NSMutableOrderedSet properties for the unordered and ordered to-many relationships respectively.

I was lazy, however, and didn't want to go back and rewrite all of my code to use these properties. So instead, I created a patch that adds "fixed" methods for ordered sets to the computer-version of the generated models.

See this pull request:

rentzsch/mogenerator#181

For me, this is a better solution than having this "fix" included in MagicalRecord... mogenerator was designed to make CoreData work better than the junk Apple provides by default, so I think it's more appropriate that the fix go there for this.

For these reasons, I am leaving this pull request closed.

@getchare
Copy link

Hi @JRG-Developer,
thanks for your answer, I've really appreciated its completeness.
I've ended using Mogenerator (I was already planning to use it), it seems a better solution than patching manually this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants