On Jun 20, 2009, at 11:08, Jean-Daniel Dupas wrote:

- (void)dealloc {
 [_object release];
 [super dealloc];
}

Try changing this to:

- (void) dealloc {
        self.object = nil;
        [super dealloc];
}

'keyPathsForValuesAffectingName' is going to cause your wrapper to observe its MyObject (not the observation that you set up manually, but a different one set up internally). When the wrapper deallocs, there's apparently nothing to cause this internal observation to be removed, so the MyObject continues to be observed by a deallocated object. At least, that's my theory.

Note that if each wrapper had its own object (so the MyObject is a "attribute" of the wrapper), then [_object release] would actually dealloc the MyObject, which (if I've got things the right way round) would cause the unwanted observation to be removed automatically.

But you actually have a 1-1 relationship between the wrapper and the MyObject, so you kind of need to break the relationship before releasing the wrapper end of it.

_______________________________________________

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 arch...@mail-archive.com

Reply via email to