On Mar 17, 2012, at 20:03 , Ken Thomases wrote:
> It's an important part of the semantics of a property whether it holds a
> strong or weak reference.
On Mar 17, 2012, at 20:04 , Greg Parker wrote:
> The memory management behavior of a property frequently is part of the public
> interface. For example, if you want to understand your retain cycles then
> it's important to know which properties are strong and which are weak. Or if
> you have a mutable string then it's important to know which properties are
> retaining and which are copying.
Yes, there's important information, but -- correct me if I'm wrong -- what you
really need to know is:
What ownership stake does the property taken in objects you set as
values?
In the pre-ARC retain/release memory model, 'retain' meant "takes ownership"
and 'assign' meant "doesn't take ownership", and there weren't any strong or
weak references as such.
In ARC, the client still doesn't really care about the kind of *reference* the
implementation holds internally. It still only cares whether setting the
property affects retain cycles, as you said. It only cares about ownership.
In particular, if the client is ARC but the class implementation isn't, a
so-called strong property just retains its ivar and a so-called weak property
doesn't.
I shouldn't have suggested that property declarations didn't need memory
management attributes, but all of the current attributes are "wrong" (because
they do double-duty as ivar reference attributes). I *think* the "right"
property attributes should be exactly one of the following list per declaration:
owning
nonowning
copying
readonly
readwrite,owning
readwrite,nonowning
readwrite,copying
If we choose to use "strong" and "weak" for the first two of these, and forcing
double duty as ivar attributes on them, that's OK by me. I just wonder how many
people think that if you access (i.e. read) the value of a "weak" property, you
"get back" a "weak reference".
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]