Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Can't add object to ordered set #75

Open
pip8786 opened this Issue · 16 comments

8 participants

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

@rentzsch
Owner

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

@rentzsch rentzsch closed this
@robertjpayne

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
Owner

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

@batkuip

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

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

@rentzsch
Owner

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

@rentzsch rentzsch reopened this
@batkuip

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
Owner

@batkuip thanks for looking into this

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

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

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

@JRG-Developer JRG-Developer referenced this issue from a commit in JRG-Developer/mogenerator
@JRG-Developer JRG-Developer 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
@JRG-Developer

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

@fatuhoku

What's the workaround to this at the minute?

@Scenario

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

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.