On Mon, Mar 18, 2002 at 09:25:48PM +0100, Thorano wrote:
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.
Now I'm confused.
How can one declare
id objects[count]
??
count isn't resolvable at compile-time so won't the compiler complain?