Skip to content
This repository

Can't add object to ordered set #75

Open
pip8786 opened this Issue November 13, 2011 · 15 comments

7 participants

pip8786 Jonathan 'Wolf' Rentzsch rolandking Robert Payne Thomas van der Heijden Joshua Greene Hok Shun Poon
pip8786

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

#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

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

Jonathan 'Wolf' Rentzsch
Owner

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

Jonathan 'Wolf' Rentzsch rentzsch closed this November 28, 2011
Robert Payne

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.

Jonathan 'Wolf' Rentzsch
Owner

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

Thomas van der Heijden

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

Jonathan 'Wolf' Rentzsch
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.

Thomas van der Heijden

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

Jonathan 'Wolf' Rentzsch
Owner

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

Jonathan 'Wolf' Rentzsch rentzsch reopened this April 24, 2013
Thomas van der Heijden

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.

Jonathan 'Wolf' Rentzsch
Owner

@batkuip thanks for looking into this

Joshua Greene JRG-Developer referenced this issue from a commit in JRG-Developer/mogenerator November 18, 2013
Joshua Greene Added missing NSOrderedSet methods (insert, remove, replace, etc) per…
… Issue #75 comments.
13a3630
Joshua Greene

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

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

Joshua Greene JRG-Developer referenced this issue from a commit in JRG-Developer/mogenerator November 19, 2013
Joshua Greene 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).
a971c39
Joshua Greene

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

Hok Shun Poon

What's the workaround to this at the minute?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.