gnustep-dev
[Top][All Lists]
Advanced

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

Re: mutableCopy in NSArray


From: Richard Frith-Macdonald
Subject: Re: mutableCopy in NSArray
Date: Tue, 19 Mar 2002 09:39:31 +0000

On Monday, March 18, 2002, at 09:03 PM, Jonathan B. Leffert wrote:

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?

No, that's a rather nice gcc extension.




reply via email to

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