• 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: Weak link usage? @property?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Weak link usage? @property? (From: Scott Squires <email@hidden>)

  • Prev by Date: Weak link usage? @property?
  • Next by Date: NSBaselineOffsetAttributeName support in NSTextField - bug? Re: how to prevent baseline shift when using NSSuperscriptAttributeName on a NSTextView's NSAttributedString ?
  • Previous by thread: Weak link usage? @property?
  • Next by thread: Re: Weak link usage? @property?
  • Index(es):
    • Date
    • Thread