Re: NSArray behavior changes ?
Re: NSArray behavior changes ?
- Subject: Re: NSArray behavior changes ?
- From: Ondra Cada <email@hidden>
- Date: Fri, 21 Sep 2001 11:20:49 +0200
Raphael,
>
>>>>> Raphael Sebbe (RS) wrote at Fri, 21 Sep 2001 11:05:05 +0200:
RS> I have a NSMutableArray that I want to copy (immutable). Basically :
RS>
RS> NSArray *array;
RS> array = [marray copy];
RS>
RS> The objects in marray implement NSCopying but are *not* copied, but
RS> retained instead. This seems to have changed since the released builds
RS> of OS X, when objects in the array were copied. Could someone confirm it
RS> has ? Perhaps I am totally wrong, but that code has worked for a long
RS> time and suddenly broke...
Quite the contrary. The code was broken in OSX (making those unnecessary
copies), and now was corrected (to work as designed almost ten years ago).
Instances of immutable classes generally should not make copies on -copy,
but just return themselves retained. That can be a *VERY* considerable
optimalization, both memory- and speed-wise. Since the instance is immutable,
there's no disadvantage.
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc