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

Implement ordered set accessors #140

Merged
merged 1 commit into from
Jan 14, 2013
Merged

Implement ordered set accessors #140

merged 1 commit into from
Jan 14, 2013

Conversation

danielctull
Copy link
Contributor

The Apple generated accessors for ordered sets crash, this is described further in the radar bugs listed below.

I've added implementations for ordered to-many relationships, but because of Xcode will warn you about not implementing all the methods in a category, I've separated each relationship's accessor method declarations.

After two iterations of OS I would have thought they would have fixed this bug. :-/

Those radars:
http://openradar.appspot.com/10946479
http://openradar.appspot.com/12085926
http://openradar.appspot.com/11119497
http://openradar.appspot.com/12418689

@rentzsch
Copy link
Owner

rentzsch commented Dec 3, 2012

I'm not sure this patch fixes the problem.

Try re-enabling the section in mogenerator/test/test.m that has the comment "Unforunately this section..." and running rake in the test dir.

With the section enabled and without this patch, I'm seeing the old broken NSInvalidArgumentException behavior under 10.8.2/Xcode 4.5.2.

With your patch the insertion doesn't immediately raise an exception (yay!), but the relationship doesn't seem to be populated (NSCAssert([homer.children count] == 2, nil); fails).

@danielctull
Copy link
Contributor Author

Sorry for the delayed response, I thought I'd go away and come back with an answer, but in reality I've not had the time. I ran the tests and saw the failure, and this has given me doubt about using ordered sets at all, because it likely explains what I was seeing in my project.

Given deadlines, the solution I've used is to avoid using ordered sets. :-/

@rentzsch
Copy link
Owner

@danielctull No problem, we're all busy. Thanks for this and your previous patches.

@rentzsch
Copy link
Owner

For reference, here's Graham Lee's workaround:

to get them working with bindings I created a custom NSMutableArray subclass that wraps the ordered set

dmakarenko pushed a commit to dmakarenko/mogenerator that referenced this pull request Jan 3, 2013
…' prototypes/bodies specifically for ordered relationships (issue rentzsch#140).
dmakarenko pushed a commit to ef-ctx/mogenerator that referenced this pull request Jan 3, 2013
…' prototypes/bodies specifically for ordered relationships (issue rentzsch#140).
rentzsch added a commit that referenced this pull request Jan 14, 2013
@rentzsch rentzsch merged commit e11ffaf into rentzsch:master Jan 14, 2013
@richardbuckle
Copy link

I think I may have got to the bottom of this.

According to Apple's Key-Value Coding Programming Guide, for an ordered relationship we should not declare methods of the form add<Key>Object: and remove<Key>Object:, but of the form insertObject:in<Key>AtIndex: and removeObjectFrom<Key>AtIndex:, and optionally replaceObjectIn<Key>AtIndex:withObject: or replace<Key>AtIndexes:with<Key>:.

ddrccw pushed a commit to ddrccw/mogenerator that referenced this pull request Jan 20, 2014
ddrccw pushed a commit to ddrccw/mogenerator that referenced this pull request Jan 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants