Re: WTF? How can this work?
Re: WTF? How can this work?
- Subject: Re: WTF? How can this work?
- From: John Hörnkvist <email@hidden>
- Date: Sun, 19 Aug 2001 12:34:11 +0200
On Sunday, August 19, 2001, at 05:30 AM, Mike Beam wrote:
Now of course when I compile this I get the warning that NSArray doesn't
respond to addObject:, but when I run the app, enter some text into the
textfield and hit enter, thereby invoking add:, in the console appears
my
text as an array description. Repeating this adds newly typed text
into the
array and displays in the PB console the description of the array, with
the
newly added elements.
Again, maybe I'm *completely* missing something fundamental here, but I
though NSArrays were _immutable_. It seems like this one here is
behaving
exactly like an NSMutableArray. Is this behavior correct? Did the
compiler
notice me trying to send addObject to an NSArray and decide that I
really
wanted array to be typed NSMutableArray? Any help would be appreciated.
We had a long discussion on this on email@hidden; search the
list archives on "NEWBIE : class names ?" and "The mutable-immutable
issue".
In essence, the problem is that Apple has chosen to implement NSArray
and NSMutableArray with the same class. I regard this as a bug.
Regards,
John Hornkvist
--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com