On Apr 13, 2008, at 9:41 PM, Adam R. Maxwell wrote:

Whenever you call out from your dealloc method (ie. any method you call on some other object than self, and even any method on self that you haven't implemented in your own class, or that could be overridden by subclasses) you invite problems.

As a concrete example, I ran into exactly this problem with an override of -[NSView discardCursorRects] (which had a radical documentation change from 10.4 to 10.5 and now sounds much less useful). NSView's dealloc invokes -discardCursorRects, and my override was accessing an ivar that had already been deallocated. At least that particular special case is now documented.

This makes sense. However if I get into the habit of setting every ivar to nil without understanding the background why I have to do it, I will have the feeling that some foreign substances are swimming in my code.

Maybe it is possible to invoke dealloc twice in multithreaded applications? And setting to nil prevents an exception like BAD_ACCESS if this happens?

Ferhat





_______________________________________________

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