• 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: Sat, 29 Sep 2001 15:02:14 +0200

jgo,

>>>>>> jgo (j) wrote at Sat, 29 Sep 2001 02:19:38 -0700:
j> >Instances of immutable classes generally should not make copies
j> >on -copy, but just return themselves retained...
j>
j> If it doesn't do a copy, why is it called "copy"?
j> If you merely want to retain, why not do a retain?

You are too bound to the implementation. Forget it, and just use API -- it
will allow you to write programs *much* more efficiently.

In this particular case, you use 'retain' if you want to use a (potentially)
shared object; you use 'copy' if you want to have your own safe snapshot,
which won't be changed by anybody.

The actual implementation -- whether any copying is done or not -- is
utterly unimportant. In principle (with some quite exotic, but valid,
environment) it is even imaginable that "copy" would _always_ return the same
object (even for mutable ones), with some very sophisticated copy-on-write
(probably hardware-supported) feature.
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc


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

  • Prev by Date: Re: "static" typing (Learning Cocoa Chapter 13)
  • 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