On Feb 4, 2015, at 05:43 , Jonathan Mitchell <[email protected]> wrote: > >>> Is it normal for superclasses to message during dealloc? > > I would still like to know what people’s expectations are here.
It is normal for classes to message during dealloc, so it’s normal for superclasses to do so. However, it’s always been treacherous, for two reasons: 1. In general, using dealloc to release resources can lead to very subtle circular race conditions between objects. 2. In general, you don’t know whether it’s safe to send a message to a partially deallocated object, unless you know the exact details of the implementation, including superclasses. You’ve come unstuck with case 2. If you were in control of the implementation, you could set _objectValue to nil directly, but you’re not and you can’t. If this were the old days, pre-ARC, you could invoke [super dealloc] first, though you’d have to assume that there were no subclasses being messed up by that. In a sense, your existing objectValue solution was always wrong, because you never knew for certain whether all changes to the property value went through the setter. The same is true of representedObject, although in that case you might be prepared to bet on your assumptions never failing. _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
