Re: Weak link usage? @property?
Re: Weak link usage? @property?
- Subject: Re: Weak link usage? @property?
- From: "Shawn Erickson" <email@hidden>
- Date: Mon, 21 Jul 2008 15:25:11 -0700
On Mon, Jul 21, 2008 at 3:07 PM, Scott Squires <email@hidden> wrote:
> So what's the correct form of weak linking to avoid retain cycles?
>
> If I have an instance variable in my child of it's parent:
>
> @interface MyChild blah blah...
> {
>
> MyParentClass * myParent;
> }
> @property (nonatomic) MyParentClass * myParent;
>
> Provides this warning.
>
> warning: no 'assign', 'retain', or 'copy' attribute is specified - 'assign'
> is assumed
> warning: 'assign' attribute (default) not appropriate for non-gc object
> property 'myParent'
>
> Do I need to avoid any @property settings for any weak linked objects and
> just deal with directly in my methods?
assign - just assigns (pointer copy)
retain - assign and retains
copy - assigns a copy of the object
<http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_3.html#//apple_ref/doc/uid/TP40002974-CH4-SW38>
Assign in a non-GC world is a weak reference. If you specifically
state you want assignment you wont get a compiler warning.
-Shawn
_______________________________________________
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