On Sun, Sep 21, 2008 at 5:04 PM, Rick Mann <[EMAIL PROTECTED]> wrote: > According to the Obj-C 2.0 docs: > >> assign >> Specifies that the setter uses simple assignment. This is the default. >> >> If your application uses garbage collection, if you want to use assign for >> a property whose class adopts the NSCopying protocol you should specify the >> attribute explicitly rather than simply relying on the default—otherwise you >> will get a compiler warning. (This is to reassure the compiler that you >> really do want to assign the value, even though it's copyable.) >> > > But the warning is: > > "warning: 'assign' attribute on property 'portName' which implements > 'NSCopying' protocol not appropriate with -fobjc-gc-only" > > So, is it really inappropriate? It seems very appropriate to assign the > pointer rather than allocate a new object and copy it, especially for > immutable objects.
I'd guess that it's considered inappropriate because "assign" has the implication that the property is a weak reference, but it will be a strong reference under GC*. Use "retain", as it implies the correct strong reference semantics, but when running under GC will generate a straight-assignment setter. * A property can be made weak by declaring its backing ivar as __weak, but this is somewhat unusual, and in any case is not affected by the property declaration. Mike
_______________________________________________ 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]