Re: NSArray behavior changes?
Re: NSArray behavior changes?
- Subject: Re: NSArray behavior changes?
- From: Andreas Monitzer <email@hidden>
- Date: Sat, 29 Sep 2001 14:17:12 +0200
On Saturday, September 29, 2001, at 11:19 , jgo wrote:
Ondra Cada wrote:
Raphael Sebbe wrote at Fri, 2001-09-21 11:05:05 +0200:
I have a NSMutableArray that I want to copy (immutable). Basically :
NSArray * array;
array = [marray copy];
Instances of immutable classes generally should not make copies
on -copy, but just return themselves retained...
If it doesn't do a copy, why is it called "copy"?
If you merely want to retain, why not do a retain?
When you get an NSArray* from the outside, you can't be sure if it's an
NSArray or NSMutableArray. When you retain an NSMutableArray, someone
could change the items under your a** (not related to AppleScript :).
Sending -copy makes sure you get a fixed list of items, in whatever way.
It wouldn't really make sense to copy a fixed list of items, though.
andy
--
God created the universe in 6 days because He didn't have to worry about
an installed base.