Re: NSArray behavior changes?
Re: NSArray behavior changes?
- Subject: Re: NSArray behavior changes?
- From: Ondra Cada <email@hidden>
- Date: Sat, 29 Sep 2001 15:02:14 +0200
jgo,
>
>>>>> jgo (j) wrote at Sat, 29 Sep 2001 02:19:38 -0700:
j> >Instances of immutable classes generally should not make copies
j> >on -copy, but just return themselves retained...
j>
j> If it doesn't do a copy, why is it called "copy"?
j> If you merely want to retain, why not do a retain?
You are too bound to the implementation. Forget it, and just use API -- it
will allow you to write programs *much* more efficiently.
In this particular case, you use 'retain' if you want to use a (potentially)
shared object; you use 'copy' if you want to have your own safe snapshot,
which won't be changed by anybody.
The actual implementation -- whether any copying is done or not -- is
utterly unimportant. In principle (with some quite exotic, but valid,
environment) it is even imaginable that "copy" would _always_ return the same
object (even for mutable ones), with some very sophisticated copy-on-write
(probably hardware-supported) feature.
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc