• 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: Ugly bug in Foundation, beware!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ugly bug in Foundation, beware!


  • Subject: Re: Ugly bug in Foundation, beware!
  • From: Andy Lee <email@hidden>
  • Date: Thu, 3 Jun 2004 12:02:12 -0400

On Jun 3, 2004, at 9:05 AM, Ondra Cada wrote:
just bumped into this: mutable arrays do *NOT* deep copy upon receiving
-copy

Given the demonstrated breadth of your knowledge from past threads, I found this statement really weird. Smalltalk collections don't deep-copy, the -copy method in NextStep didn't deep-copy, Java doesn't deep-copy, and I'll bet C++ doesn't deep-copy. Whether you think it should or not, I'm wondering how on earth you could have been assuming all this time that Foundation's collections deep-copy! Weird.

(I also think it's weird that you think deep copy *should* be the expected behavior, but others have already argued that point.)

On Jun 3, 2004, at 11:08 AM, Nicko van Someren wrote:
I was asserting that an NSArray is an array of references. A copy of an array of references is a new array containing the same references.

I think this summed up the shallow-copy explanation best.

On Jun 3, 2004, at 11:08 AM, Nicko van Someren wrote:
If you know that the objects in the container are going to be able to comply with the copying protocol then you can explicitly say so by using -initWithArray:copyItems: instead.

I didn't know about that method. Nice to know.

You could also add your own -deepCopy method in a category of NSObject. I did something like that in NextStep, using the archive-unarchive technique. I wouldn't mind having that added to Foundation as a convenience method -- with caveats on its usage, just as there are for shallow-copy.

--Andy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Ugly bug in Foundation, beware! (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: Problems linking a standalone Java Cocoa app
  • Next by Date: Re: Ugly bug in Foundation, beware!
  • Previous by thread: Re: Ugly bug in Foundation, beware!
  • Next by thread: Re: Ugly bug in Foundation, beware!
  • Index(es):
    • Date
    • Thread