• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Clarification on accessors? (was: Yet another memory management question)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Clarification on accessors? (was: Yet another memory management question) (From: Caleb Strockbine <email@hidden>)

  • Prev by Date: CGSRegisterNotifyProc and unlock screen notification
  • Next by Date: Re: Waiting on NSTableView to finish changing selection
  • Previous by thread: Clarification on accessors? (was: Yet another memory management question)
  • Next by thread: Re: Clarification on accessors? (was: Yet another memory management question)
  • Index(es):
    • Date
    • Thread