discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question on NSPointerArray +pointerArrayWithWeakObjects


From: Richard Frith-Macdonald
Subject: Re: Question on NSPointerArray +pointerArrayWithWeakObjects
Date: Fri, 4 Feb 2011 21:56:24 +0000

On 4 Feb 2011, at 21:44, Richard Frith-Macdonald wrote:

> 
> On 4 Feb 2011, at 21:23, Philippe Roussel wrote:
> 
>> I've been browsing the Apple documentation for a long time but can't
>> find the answer so here's the question : is a NSPointerArray created
>> with pointerArrayWithWeakObjects supposed to retain the objects you add
>> to it ? 
> 
> No ...'weak', as I understand it, means that the garbage collector is free to 
> collect the objects.
> 
>> In GNUstep +pointerArrayWithWeakObjects calls the init function with
>> NSPointerFunctionsZeroingWeakMemory which translate to retain but no
>> release.
> 
> A test on OSX would be nice ... but in GNUstep currently, if you specify weak 
> memory in a non-gc environment, the object is *not* retained.
> 
>> Shouldn't it be NSPointerFunctionsZeroingWeakMemory |
>> NSPointerFunctionsOpaquePersonality ?
> 
> No, because NSPointerFunctionsOpaquePersonality means that we shouldn't treat 
> the pointers as objects, and the +pointerArrayWithWeakObjects: method is 
> supposed to create an array for storing objects.
> 
> But, everything I say is based on my reading of the documentation!  My 
> understanding of the documentation may not match what apple implemented.
> If you want definitive answers to these questions, please write more 
> testcases for the testsuite at 
> http://svn.gna.org/viewcvs/gnustep/tests/testsuite/trunk/base/NSPointerArray/
> We can run those on OSX, see how it behaves, and then alter GNUstep to match 
> if necessary.

Actually, I did that just now ... and I can confirm that adding an object to 
such an array does NOT change the object's retain count.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]