On 9/24/08 3:56 PM, Quincey Morris said:

>> Is that wrong?
>
>I think so. Your "else" statement does what the documentation tells
>you not to do.

Indeed.

>IAC, it's not clear why you need to use setPrimitiveValue: at all.

Thank you for your fresh perspective.  That did not occur to me, no
doubt due to looking at this for too long. :)

>Why
>not something like:
>
>       - (void)setChildren:(NSSet*)value_
>       {
>               [[self mutableSetValueForKey:@"children"] removeAllObjects];
>               [[self mutableSetValueForKey:@"children"] unionSet: value_];
>       }
>
>or:
>
>       @dynamic addChildren;
>       @dynamic removeChildren;
>       - (void)setChildren:(NSSet*)value_
>       {
>               [self removeChildren: [NSSet setWithSet: self.children]];
>               [self addChildren: value_];
>       }
>
>both of which have the advantage of maintaining the inverse
>relationship properly, which your original (according to the
>documentation) does not.

Those look good.  After looking at "Custom To-Many Relationship Accessor
Methods" yet again, another implementation comes to mind, which fits
nicely with Apple's examples:

- (void)setChildren:(NSSet *)value_
{
  [self willChangeValueForKey:@"children"
    withSetMutation:NSKeyValueSetSetMutation
    usingObjects:value_];
  [[self primitiveChildren] setSet:value];
  [self didChangeValueForKey:@"children"
    withSetMutation:NSKeyValueSetSetMutation
    usingObjects:value_];
}

The reason I bring this up, is because I noticed that mogenerator 1.10
is generating code that incorrectly uses setPrimitiveValue:forKey: as
originally described.

Thanks Quincey!

--
____________________________________________________________
Sean McBride, B. Eng                 [EMAIL PROTECTED]
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to