__weak references in non-GC
-
I read the following passage (reproduced verbatim) in a book ..
"Weak references were added in Mac OS X Leopard and effectively zero out the reference if the referenced object is released. This is primarily used when the garbage collector is turned on, but it is a helpful flag to use when doing non-GC development (such as for the iPhone) as well."
This is in a paragraph explaining __weak in a piece of code.
I understand that __weak references are zeroing in GC code but in memory managed code I didn't think they did anything at all. Is the text I quoted incorrect? -
On 1 feb 2010, at 06.08, Roland King wrote:
> I understand that __weak references are zeroing in GC code but in memory managed code I didn't think they did anything at all. Is the text I quoted incorrect?
Yes, __weak doesn't do anything for RC.
j o a r -
On Feb 1, 2010, at 6:08 AM, Roland King wrote:
> I read the following passage (reproduced verbatim) in a book ..
>
> "Weak references were added in Mac OS X Leopard and effectively zero out the reference if the referenced object is released. This is primarily used when the garbage collector is turned on, but it is a helpful flag to use when doing non-GC development (such as for the iPhone) as well."
>
> This is in a paragraph explaining __weak in a piece of code.
>
> I understand that __weak references are zeroing in GC code but in memory managed code I didn't think they did anything at all. Is the text I quoted incorrect?
As Joar said, it doesn't do anything for the runtime. However, I think the statement was referring to it being a useful flag for the programmer to know it is a weak (non retained) variable.
--corbin


