• 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: Objective 2.0 properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective 2.0 properties


  • Subject: Re: Objective 2.0 properties
  • From: Jim Correia <email@hidden>
  • Date: Sat, 18 Oct 2008 09:35:47 -0400

On Oct 17, 2008, at 2:29 PM, Jim Correia wrote:

For object types, in a non-garbage collected application (traditional retain/release style memory management) you never want to use assign. It is the equivalent of hand writing an accessor that does a pointer assignment (with no additional memory management) - i.e. it is incorrect.

My previous advice that, for object type properties in a non-GC application, you never want to use assign, was an oversimplification and therefore incorrect. Let me correct that advice for the benefit of the archives.


For object types which are acting as attributes (i.e. name, color), assign is never what you want (and you'll end up violating the object ownership policy.) You'll want to use copy for objects which conform to NSCopying, retain for other types.

For object types which are acting as relationships, you usually want retain, but sometimes assign is appropriate here, if you want or need a weak/non-retained reference. Examples of this are delegates, references to parents in a tree structure (to prevent retain cycles.)

The key point here is that using assign, in a non-GC app, for an object type, is a special case. (And you need to understand that the special case applies to you, and you are using assign for the right reasons.)

Jim
_______________________________________________

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: 
 >Objective 2.0 properties (From: "Ignacio Enriquez" <email@hidden>)
 >Re: Objective 2.0 properties (From: Charles Steinman <email@hidden>)
 >Re: Objective 2.0 properties (From: "Ignacio Enriquez" <email@hidden>)
 >Re: Objective 2.0 properties (From: Jim Correia <email@hidden>)
 >Re: Objective 2.0 properties (From: "Ignacio Enriquez" <email@hidden>)
 >Re: Objective 2.0 properties (From: Jim Correia <email@hidden>)

  • Prev by Date: Re: Screen not redrawing
  • Next by Date: Re: 10.4 v. 10.5 SDK question
  • Previous by thread: Re: Objective 2.0 properties
  • Next by thread: Re: Objective 2.0 properties
  • Index(es):
    • Date
    • Thread