Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Memory cleanup when init fails?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory cleanup when init fails?



Sean,

On Oct 1, 2008, at 6:51 PM, Sean McBride wrote:

I know the above is an example, but... it is generally preferable to
not use setter accessors in init, it is better to set the ivars directly:


There was a pretty heated debate once.

Not to repeat all the arguments of both sides, I daresay now with Objective C 2.0 we can safely conclude that the _current_ recommendation is the very opposite of what you are pointing out: we _should_ use setters in init (and dealloc and anywhere else).

The reason is extremely simple: we should do that all the time, since (a) sometimes we just _have to_*, (b) and it's better to keep consistent in the others cases.

The (a) is indisputable. The (b) of course can be argued, but at least for me, in this case I consider inconsistence _considerably_ worse source of potential errors and problems.

*Namely, if you use @synthesize to generate the ivar for a 64-bit environment, there is no standard way to access the ivar directly.

Best,
---
Ondra Čada
OCSoftware:     email@hidden               http://www.ocs.cz
private         email@hidden             http://www.ocs.cz/oc



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Memory cleanup when init fails? (From: "Sean McBride" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.