On Aug 5, 2008, at 3:00 AM, mmalc crawford wrote:

No, this is not the case -- Ken's reply was correct. If you use automatic KVO notifications, your accessors will still have side effects.

Although I should add that of course by the time you reach dealloc you should not have observers...

The general point still stands, though.  The correct pattern is:
Set instance variables directly in init methods, and release them directly in dealloc.

On Aug 5, 2008, at 2:57 AM, Uli Kusterer wrote:

Though I vaguely remember getting lectured by someone about why it's better to *always* use the accessors a while ago ... wish I remembered what the reasoning behind that was, and why I thought it might be a good idea to follow that, but OTOH didn't follow it :-/

Other than in init, you should always use accessors to set values because: (a) The accessors might have side-effects (such as emitting KVO change notifications) that your application relies on; (b) Accessors are typically the best place to put memory management code. If you push "all" your memory management to accessors, then you're much less likely to make a mistake somewhere along the line...

mmalc

_______________________________________________

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