FROM : Jonathan Dann
DATE : Sun Jan 06 20:32:12 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
DATE : Sun Jan 06 20:32:12 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






Cocoa mail archive

