On Sep 24, 2008, at 3:56 PM, Quincey Morris wrote:

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

        - (void)setChildren:(NSSet*)value_
        {
                [[self mutableSetValueForKey:@"children"] removeAllObjects];
                [[self mutableSetValueForKey:@"children"] unionSet: value_];
        }

In addition to what Ben has said, the above code is incorrect and should not be used. It's not just incorrect as a Core Data accessor/ mutator method -- it doesn't post KVO will/did notifications around the property mutation -- but it's also incorrect from a general Cocoa/ KVC perspective.

The reason is that it's using -mutableSetValueForKey: in the implementation of one of the mutators that -mutableSetValueForKey: may call, giving the potential for infinite recursion. In other words, sending -setChildren:, which as part of -unionSet: could potentially send -setChildren:, which as part of -unionSet:...

The -mutable{Array,Set}ValueForKey{Path}: methods are covers for your properties, not implementation helpers for your properties.

  -- Chris

_______________________________________________

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