gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mutableCopy in NSArray


From: Jonathan B. Leffert
Subject: Re: mutableCopy in NSArray
Date: Mon, 18 Mar 2002 13:03:55 -0800
User-agent: Mutt/1.2i

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?

Jonathan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]