• 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: Ondra Cada <email@hidden>
  • Date: Fri, 21 Sep 2001 11:20:49 +0200

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


  • Follow-Ups:
    • Re: NSArray behavior changes?
      • From: jgo <email@hidden>
    • Re: NSArray behavior changes ?
      • From: Stefan Jung <email@hidden>
References: 
 >NSArray behavior changes ? (From: Raphael Sebbe <email@hidden>)

  • Prev by Date: Re: Spelling in classes
  • Next by Date: Re: Spelling in classes
  • Previous by thread: NSArray behavior changes ?
  • Next by thread: Re: NSArray behavior changes ?
  • Index(es):
    • Date
    • Thread