• 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: strong and readonly
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strong and readonly


  • Subject: Re: strong and readonly
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 12 Apr 2012 00:50:25 -0700

On Apr 11, 2012, at 23:58 , Thomas CLEMENT wrote:

Isn't that exposing implementation details of the class that have nothing to do in its public header?

This was discussed on this list (or perhaps cocoa-dev) a week or two ago. I believe I'm summarizing the result of that discussion as follows:

The "strong" or "weak" on the @property is indeed an implementation detail in that it affects the implied declaration of a *synthesized* ivar, and the implied memory management protocol with a *synthesized* setter method. In that sense, it "really" shouldn't be on the @property but on the @synthesize instead, but that's not going to happen, in part because @synthesize is being generally de-emphasized these days.

However, the "strong" and "weak" (or "retain" and "assign", in the old days) still serve a purpose on the @property, because they inform clients of the class's API of the value object ownership behavior for the property. With "strong" or "retain", the property makes an API contract to take ownership of value objects in its setter. With "weak" or "assign", it does not take ownership. In neither case is there any API contract about the mechanism the property *actually* uses to provide that ownership behavior. (In particular, you don't know if the class uses ARC or traditional retain/release internally, in a non-GC app. And you don't know whether it @synthesized or not.)

In addition to the above, you have other cases like "copy", which affects the API contract for ownership, and affects any synthesized setter code, but has no meaning for the ivar itself.

I don't think this situation is ideal, but I have to admit that in practice there's no real problem. (Clients can't really exploit the exposed private details, I think.)


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: strong and readonly
      • From: Rick Mann <email@hidden>
    • Re: strong and readonly
      • From: Thomas Davie <email@hidden>
References: 
 >strong and readonly (From: Rick Mann <email@hidden>)
 >Re: strong and readonly (From: David Duncan <email@hidden>)
 >Re: strong and readonly (From: Thomas CLEMENT <email@hidden>)

  • Prev by Date: Re: strong and readonly
  • Next by Date: Re: strong and readonly
  • Previous by thread: Re: strong and readonly
  • Next by thread: Re: strong and readonly
  • Index(es):
    • Date
    • Thread