On 13-Apr-08, at 12:02 PM, [EMAIL PROTECTED] wrote:
why is it necessary to set the variable appointments (for instance) to nil in this example? Should we do this for each variable? When have we to do
this?

IMO, it's totally unnecessary.  Seems to be a cargo culting thing more
than anything else.


No, I can personally assure you that exact practice has led me to finding many dozens -- quite possibly several hundreds by now actually -- of 'calling methods of a deleted object' type bugs in C++ code, particularly game code I port from Windows, which somehow always seems to have been written by semi-literate chimpanzees on crack. And perhaps I am unfair to the chimpanzees here.

It does seem that class of problem is much less likely to arise with Objective-C object references (I'm still fairly new to this Cocoa thing) but as long as I still work with any C++ objects or raw pointers, I'm going to consider that "set things up so anything accessing this object's memory after I'm done with it promptly causes an access violation" is a valuable habit -- nay, essential practice -- in properly defensive programming. Autoptrs and the like help, but they're not foolproof. Stands to reason that the retain/[auto]release paradigm isn't completely foolproof either, although it does seem pretty resistant to commonly accepted levels of foolery so far.

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

There are two great secrets to success in life.
The first is to not tell everything you know.

_______________________________________________

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