You want to just leave the pointer alone and turn on NSZombiesEnabled when you run your app. Then instead of the object on the other end of the pointer being freed, it'll point to a special zombie class which will helpfully raise you an exception when you try to send it a message. This has the added advantage of being able to more easily see what the pointer _used_ to point to, because the zombie has information about the original class name.

        - Greg

On Apr 13, 2008, at 1:35 PM, Alex Curylo wrote:

On 13-Apr-08, at 1:06 PM, Greg Titus wrote:
The big difference is that in Objective-C, trying to send a message to nil results in a no-op instead of an access violation, so your defensive C++ practice is actually going to tend to mask those same errors in Objective-C and make them harder to track down.

*smacks forehead*

Yeah, now that I actually think about it, that would be the effect, wouldn't it. Just hadn't made the connection up 'til now, somehow. Thank you.

OK, then, what would an equivalently useful value to set a released Objective-C object pointer/ivar to in order to cause any subsequent access of it to stop the program immediately? 0xDEADBEEF perhaps?

--
Alex Curylo -- [EMAIL PROTECTED] -- http://www.alexcurylo.com/

Programming is like sex...
One mistake and you support it the rest of your life.





_______________________________________________

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