Can't add object to ordered set #75

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

Comments

Projects
None yet
9 participants
@pip8786

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

This comment has been minimized.

Show comment
Hide comment
@pip8786

pip8786 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?

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

This comment has been minimized.

Show comment
Hide comment
@rolandking

rolandking Nov 27, 2011

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).

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

This comment has been minimized.

Show comment
Hide comment
@rentzsch

rentzsch Nov 28, 2011

Owner

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

Owner

rentzsch commented Nov 28, 2011

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

@rentzsch rentzsch closed this Nov 28, 2011

@robertjpayne

This comment has been minimized.

Show comment
Hide comment
@robertjpayne

robertjpayne Sep 19, 2012

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.

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

This comment has been minimized.

Show comment
Hide comment
@rentzsch

rentzsch Sep 22, 2012

Owner

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

Owner

rentzsch commented Sep 22, 2012

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

@batkuip

This comment has been minimized.

Show comment
Hide comment
@batkuip

batkuip Apr 15, 2013

Contributor

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

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

This comment has been minimized.

Show comment
Hide comment
@rentzsch

rentzsch Apr 15, 2013

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.

Owner

rentzsch commented Apr 15, 2013

@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

This comment has been minimized.

Show comment
Hide comment
@batkuip

batkuip Apr 23, 2013

Contributor

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

Contributor

batkuip commented Apr 23, 2013

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

@rentzsch

This comment has been minimized.

Show comment
Hide comment
@rentzsch

rentzsch Apr 24, 2013

Owner

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

Owner

rentzsch commented Apr 24, 2013

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

@rentzsch rentzsch reopened this Apr 24, 2013

@batkuip

This comment has been minimized.

Show comment
Hide comment
@batkuip

batkuip Apr 24, 2013

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@rentzsch

rentzsch Apr 25, 2013

Owner

@batkuip thanks for looking into this

Owner

rentzsch commented Apr 25, 2013

@batkuip thanks for looking into this

@JRG-Developer

This comment has been minimized.

Show comment
Hide comment
@JRG-Developer

JRG-Developer Nov 20, 2013

Contributor

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

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

Contributor

JRG-Developer commented Nov 20, 2013

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

Fixed issues in previous code.
See Issue #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

This comment has been minimized.

Show comment
Hide comment
@JRG-Developer

JRG-Developer Nov 20, 2013

Contributor

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

Contributor

JRG-Developer commented Nov 20, 2013

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

@fatuhoku

This comment has been minimized.

Show comment
Hide comment
@fatuhoku

fatuhoku Apr 2, 2014

What's the workaround to this at the minute?

fatuhoku commented Apr 2, 2014

What's the workaround to this at the minute?

@Scenario

This comment has been minimized.

Show comment
Hide comment
@Scenario

Scenario Jul 23, 2014

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

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

This comment has been minimized.

Show comment
Hide comment
@justin

justin Dec 26, 2015

Collaborator

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.

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 Dec 26, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment