• 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: Nicko van Someren <email@hidden>
  • Date: Thu, 3 Jun 2004 14:52:30 +0100

On 3 Jun 2004, at 14:05, Ondra Cada wrote:

just bumped into this: mutable arrays do *NOT* deep copy upon receiving
-copy
...
Didn't check mutable sets, dicts, et cetera, but i'd bet they share
this howler :(((((

What makes you think that this is a bug and not a design feature? The array class knows nothing of the objects it holds, it simply holds a set of pointers. The copy of the array contains copies of those pointers. The implementation of -copy and -copyWithZone: are explicitly stated as being up to the class.

If you need a copy of an array with copies of the objects that it holds you can use
NSArray *a, *b;
...
b = [[NSArray alloc] initWithArray: a copyItems: YES];
Of course this is still not a true deep copy since all it does to copy the items is send them a -copyWithZone: message.

Nicko
_______________________________________________
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.


  • Follow-Ups:
    • Re: Ugly bug in Foundation, beware!
      • From: Ondra Cada <email@hidden>
References: 
 >Ugly bug in Foundation, beware! (From: Ondra Cada <email@hidden>)

  • Prev by Date: Is that really a bug at all? (was: Re: Ugly bug in Foundation, beware!)
  • Next by Date: Re: Scrollview sizing/positioning questions
  • Previous by thread: Re: Is that really a bug at all? (was: Re: Ugly bug in Foundation, beware!)
  • Next by thread: Re: Ugly bug in Foundation, beware!
  • Index(es):
    • Date
    • Thread