• 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: Properties and memory management
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Properties and memory management


  • Subject: Re: Properties and memory management
  • From: Negm-Awad Amin <email@hidden>
  • Date: Tue, 5 Aug 2008 11:48:24 +0200


Am Di,05.08.2008 um 11:02 schrieb Ken Ferry:

On Tue, Aug 5, 2008 at 1:12 AM, Uli Kusterer
<email@hidden> wrote:
On 05.08.2008, at 05:55, Jonathan Hess wrote:

The implementation of the property will manage the retaining and the
releasing. You only need to worry about sending retain and release messages
manually if you access the instance variable directly (not through a
property). The only place you would typically need to do that would be in
your dealloc method.


Although in dealloc

      self.myProperty = nil;

would also work, which has the added benefit that you'll notice when you're
talking to an object that has already been released, because then all its
object ivars will be NIL.

A disadvantage of this approach is that you'll be invoking the setter when your object is partially torn down. If you later override or implement the method, you are not likely to be thinking about the possibility that the object is not in a valid state. Calling methods from init has the same issue.

You may fire off observer methods too, which is probably undesirable.
This is the "mirror" of the problem, when you initialize an object. Of course, theoretically in both cases the usage of setters are dangerous. In most cases the deallocation of the object in reverse order to its initialization will not lead to any problems. It is no problem, when you have synthisized accessors, because they have noch side-effects.

Amin


-Ken
_______________________________________________

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

Amin Negm-Awad email@hidden




_______________________________________________

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


  • Follow-Ups:
    • Re: Properties and memory management
      • From: mmalc crawford <email@hidden>
    • Re: Properties and memory management
      • From: Uli Kusterer <email@hidden>
References: 
 >Properties and memory management (From: Mike Manzano <email@hidden>)
 >Re: Properties and memory management (From: Jonathan Hess <email@hidden>)
 >Re: Properties and memory management (From: Uli Kusterer <email@hidden>)
 >Re: Properties and memory management (From: "Ken Ferry" <email@hidden>)

  • Prev by Date: Resizing a NSImage in a Cocoa command line tool
  • Next by Date: Re: image type of the AdressBook image data
  • Previous by thread: Re: Properties and memory management
  • Next by thread: Re: Properties and memory management
  • Index(es):
    • Date
    • Thread