Re: WTF? How can this work?
Re: WTF? How can this work?
- Subject: Re: WTF? How can this work?
- From: Ondra Cada <email@hidden>
- Date: Sun, 19 Aug 2001 12:07:21 +0200
Chris,
>
>>>>> Chris Gehlker (CG) wrote at Sat, 18 Aug 2001 22:18:11 -0700:
CG> >Again, maybe I'm *completely* missing something fundamental here, but I
CG> >though NSArrays were _immutable_. It seems like this one here is
CG> >behaving exactly like an NSMutableArray. Is this behavior correct? Did
CG> >the compiler notice me trying to send addObject to an NSArray and decide
CG> >that I really wanted array to be typed NSMutableArray? Any help would be
CG> >appreciated. Thanks!
CG>
CG> I'm fairly new to Cocoa but I have already learned that when you mess
CG> with class clusters undocumented behavior is, well ... Undocumented.
CG> Maybe there really is no such thing as an immutable array of strings.
CG> It's easy to envision such an optimization. Remember that there aren't
CG> any actual implementations of NSArray or NSMutableArray. The actual
CG> implementations are members of private classes we know little about.
Hmmmmm, true, *BUT*.
1st BUT: optimization: the [immutable_class copy] should just return [self
retain] -- otherwise copying would get *REALLY* slow;
2nd BUT: security: if I am using an immutable class and I make a bug of
using is as if it were a mutable one, I suppose the app would stop and write
a decent info to console!
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc