Re: NSArray behavior changes ?
Re: NSArray behavior changes ?
- Subject: Re: NSArray behavior changes ?
- From: Stefan Jung <email@hidden>
- Date: Fri, 21 Sep 2001 17:50:50 +0200
I found that on of my programs couldn't load files it created under
10.0.4 if run from 10.1.
The data were written("NSCoded") with no NSArray, but only
NSMutableArrays.
Nonetheless PB logs:
Exception raised during posting of notification. Ignored.
exception: *** -[NSCFArray sortUsingFunction:context:]: mutating method
sent to immutable object
So there is a bigger change. Under 10.0.4 NSMutableArrays are obviously
saved as NSArrays.
Stefan Jung
On Freitag, September 21, 2001, at 11:20 Uhr, Ondra Cada wrote:
>
Raphael,
>
>
>>>>>> Raphael Sebbe (RS) wrote at Fri, 21 Sep 2001 11:05:05 +0200:
>
RS> I have a NSMutableArray that I want to copy (immutable). Basically :
>
RS>
>
RS> NSArray *array;
>
RS> array = [marray copy];
>
RS>
>
RS> The objects in marray implement NSCopying but are *not* copied, but
>
RS> retained instead. This seems to have changed since the released
>
builds
>
RS> of OS X, when objects in the array were copied. Could someone
>
confirm it
>
RS> has ? Perhaps I am totally wrong, but that code has worked for a
>
long
>
RS> time and suddenly broke...
>
>
Quite the contrary. The code was broken in OSX (making those unnecessary
>
copies), and now was corrected (to work as designed almost ten years
>
ago).
>
>
Instances of immutable classes generally should not make copies on
>
-copy,
>
but just return themselves retained. That can be a *VERY* considerable
>
optimalization, both memory- and speed-wise. Since the instance is
>
immutable,
>
there's no disadvantage.
>
---
>
Ondra Cada
>
OCSoftware: email@hidden http://www.ocs.cz
>
private email@hidden http://www.ocs.cz/oc
>
_______________________________________________
>
cocoa-dev mailing list
>
email@hidden
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev