Leopard Properties and NSMutable Array

Jonathan Dann j.p.dann at gmail.com
Sun Jan 6 11:32:12 PST 2008


> At the least, that should be...
>
> 	return [array autorelease];
>
> ... unless you have GC turned on (which the use of retain/release in
> the rest of your code indicates that you likely do not).
>
> Given the overall defensiveness of your code, you might consider
> returning a copy of your array, mutable or otherwise.   As it stands,
> any client can grab a reference to the internal storage of your class
> and change it.
>
> 	return [[array copy] autorelease];

Thanks Bill, that does seem better, I'm quite new to all of this, and  
I'm being quite cautious with my memory managment, trying to get it  
*really* right.  Your explanation makes perfect sense.

Jon


More information about the MacOSX-dev mailing list