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 (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 [EMAIL PROTECTED]

Reply via email to