• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSArray behavior changes?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Re: NSArray behavior changes? (From: jgo <email@hidden>)

  • Prev by Date: Re: NSArray behavior changes?
  • Next by Date: Re: "static" typing (Learning Cocoa Chapter 13)
  • Previous by thread: Re: NSArray behavior changes?
  • Next by thread: Re: NSArray behavior changes?
  • Index(es):
    • Date
    • Thread