On 08/07/2009 17:51, "Caleb Strockbine" <ca...@mac.com> wrote:

>
> On Jul 4, 2009, at 9:37 PM, mmalc wrote:
>
>> In an initaliser method and in dealloc, you should typically set or
>> release the variable directly, so in dealloc it would be
>>     [myArray release];
>
> Really? Are -init and -dealloc special in some way that makes it a bad
> idea to use accessors? If you've got an accessor for myArray, why
> wouldn't you just say:
>
> self.myArray = nil?
>

-init and -dealloc are special in that the object is not in a consistent
state during those methods (it either hasn't yet entered it's "initial"
state or is transitioning out of its "final" state). If your accessors rely
on the internal state of the object being "normal", they could blow up when
called in these methods.

Cheers,

Graham.

--
Graham Lee
Senior Mac Software Engineer

tel: +44 1235 540266
SOPHOS - simply secure



Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United 
Kingdom.
Company Reg No 2096520. VAT Reg No GB 348 3873 20.
_______________________________________________

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 arch...@mail-archive.com

Reply via email to