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

Can't add object to ordered set #75

Closed
pip8786 opened this issue Nov 14, 2011 · 17 comments
Closed

Can't add object to ordered set #75

pip8786 opened this issue Nov 14, 2011 · 17 comments
Milestone

Comments

@pip8786
Copy link

pip8786 commented Nov 14, 2011

My VectorLayer object has an ordered to-many relationship to VectorStroke named strokes. I cannot seem to add a VectorStroke to my VectorLayer without it crashing.

I've tried adding a VectorStroke to the VectorLayer directly with the following results:
[vectorLayer addStrokesObject:vectorStroke];

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSSet intersectsSet:]: set argument is not an NSSet'

And I've tried using the strokesSet property and got the following results:
[vectorLayer.strokesSet addObject:vectorStroke];

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSManagedObjects of entity 'VectorLayer' do not support -mutableSetValueForKey: for the property 'strokes''

Am I doing something wrong or is this a bug?

@pip8786
Copy link
Author

pip8786 commented Nov 14, 2011

#66

I think this commit would help my issue but I don't see how to replace the machine.m files from an installed mogen. How do I do this?

@rolandking
Copy link

Yes that looks like it would work. You can use a command-line argument to point to your own set of files, or you can replace the ones in Library/Application Support/mogenerator (although I wouldn't suggest that).

@rentzsch
Copy link
Owner

Sorry, I missed I that I haven't shipped this fix yet. Will do so soonish.

@robertjpayne
Copy link

This issue should still be open, it's not 100% fixed.

You can use the mutableOrderedSet accessory and manipulate the set yourself now but you still cannot use the addObject accessors as it still causes a crash.

I'm not sure how much this is a mogenerator vs a Core Data bug.

@rentzsch
Copy link
Owner

@robertjpayne Thanks for the alert. Can you add a repro for this bug to /test?

@rentzsch
Copy link
Owner

@batkuip
Copy link
Contributor

batkuip commented Apr 15, 2013

Any update on this one? The CoreData bug is still there :( Would be ideal if mogen would create a working wrapper. (maybe with a command line toggle?)

http://stackoverflow.com/questions/7385439/exception-thrown-in-nsorderedset-generated-accessors

@rentzsch
Copy link
Owner

@batkuip I'd welcome a patch that generated a working wrapper for ordered sets. @robertjpayne makes it sound like using mutableOrderedSet should work.

No need for a command-line toggle, since this would make an otherwise totally-broken piece of Core Data functional.

@batkuip
Copy link
Contributor

batkuip commented Apr 23, 2013

Actually turns out the patch is already in, just not released. See commit e11ffaf

@rentzsch
Copy link
Owner

@batkuip thanks for the tip, I'll see if it actually works.

@rentzsch rentzsch reopened this Apr 24, 2013
@batkuip
Copy link
Contributor

batkuip commented Apr 24, 2013

Cheers. It's not entirely complete as it's missing the insertObject:atIndex methods (atleast that's what the xcode automatically generates in the .h file). Those methods are trickier to implement because the mutableset accessor uses mutableSetValueForKey which seems to call the insertObject:atIndex internally causing it loop forever.

@rentzsch
Copy link
Owner

@batkuip thanks for looking into this

@JRG-Developer
Copy link
Contributor

Just noticed @batkuip comments.. pull request for this code may have been premature.

I'm going to do more testing and see...

JRG-Developer added a commit to JRG-Developer/mogenerator that referenced this issue Nov 20, 2013
See Issue rentzsch#75, comment by @batkuip "Those methods are trickier to implement because the mutable set accessor uses mutableSetValueForKey which seems to call the insertObject:atIndex internally causing it loop forever."

This code creates a temporary mutable set using the ordered set (not the mutable set which loops as noted), making sure to call appropriate KVC methods.

Credit for original code/idea goes to @dmitry Makarenkoless and @jlust on StackOverFlow (http://stackoverflow.com/questions/7385439/exception-thrown-in-nsorderedset-generated-accessors).
@JRG-Developer
Copy link
Contributor

I think I've got a working solution for this. Please checkout the referenced pull request. : D

@fatuhoku
Copy link

fatuhoku commented Apr 2, 2014

What's the workaround to this at the minute?

@Scenario
Copy link

Is this the same issue as this crash, using the pre-1.28 Swift template with an ordered set's inverse relationship?

self.willAccessValueForKey("categoryForItem") <<< EXC_BAD_ACCESS code=2

@justin
Copy link
Collaborator

justin commented Dec 26, 2015

The PR for this was merged a while ago. If there are any remnants, please open a new issue and we'll work it out.

@justin justin closed this as completed Dec 26, 2015
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

No branches or pull requests

9 participants