[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mutableCopy in NSArray
From: |
Thorano |
Subject: |
Re: mutableCopy in NSArray |
Date: |
18 Mar 2002 21:25:48 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 |
RFM> GNUstep copying of container classes like NSArray follows the same rules
RFM> as MacOS-X ... for compatibility.
RFM> A mutable copy is *not* supposed to be a deep copy, rather
RFM> it's suppose supposed to produce a new container which can be modified
RFM> without affecting he original container - note, it's a copy of the
RFM> container, not its contents.
ok, I understand the spirit. But in this case [NSMutableArray copyWithZone]
is wrong :
- (id) copyWithZone: (NSZone*)zone
{
/* a deep copy */
unsigned count = [self count];
id objects[count];
NSArray *newArray;
unsigned i;
[self getObjects: objects];
for (i = 0; i < count; i++)
objects[i] = [objects[i] copyWithZone: zone];
newArray = [[GSArrayClass allocWithZone: zone]
initWithObjects: objects count: count];
while (i > 0)
RELEASE(objects[--i]);
return newArray;
}
unless there is a something else I don't understand.