Re: Clarification on accessors? (was: Yet another memory management question)
Re: Clarification on accessors? (was: Yet another memory management question)
- Subject: Re: Clarification on accessors? (was: Yet another memory management question)
- From: Graham Lee <email@hidden>
- Date: Wed, 8 Jul 2009 17:58:57 +0100
- Acceptlanguage: en-US, en-GB
- Thread-topic: Clarification on accessors? (was: Yet another memory management question)
On 08/07/2009 17:51, "Caleb Strockbine" <email@hidden> 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 (email@hidden)
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:
This email sent to email@hidden