In comp.lang.objective-c Sherm Pendley <[EMAIL PROTECTED]> wrote:
> Yeah, I'm a little skeptical of Apple's setters doing a -copy by default
> also. It seems to run counter to the whole idea of shared ownership that
> retain/release was designed to support in the first place.

Ah, but the really clever bit is that if you know that your objects are 
immutable, the retain/release mechanism lets you implement copy as a 
simple retain. Due to this, you should always copy in setters if they take 
an NSString, NSArray, etc. If it's mutable then you shouldn't be holding a 
reference to the original object anyway (it could change out from under 
you at any time) and if it's immutable then you get a very fast "copy" 
that doesn't actually do anything.

-- 
Michael Ash
Rogue Amoeba Software
_______________________________________________
Help-gnustep mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gnustep

Reply via email to