• 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: How to clone a mutable dictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to clone a mutable dictionary


  • Subject: Re: How to clone a mutable dictionary
  • From: Mike Abdullah <email@hidden>
  • Date: Sat, 25 Apr 2009 11:29:23 +0100


On 24 Apr 2009, at 17:56, Steve Cronin wrote:

Mike;

Thank-you also.  The "goodness' just doesn't stop... ;-)

My bad on the NSObject code - thanks for clarifying...
(How on earth could init yield a copy?)

But at the end of your message you say "...there's a reason why Cocoa has both -copy and -mutableCopy. .."

Is the reason you are alluding to the complications due to instance variables that is noted in the NSMutableCopying Protocol notes?
Or are you thinking of another reason?

It's because of the way Cocoa has mutable/immutable class pairs. For the mutable class in such a pair (e.g. NSMutableArray), calling -copy will return a plain NSArray. You need -mutableCopy if you specifically want the copy to be immutable. Therefore when deep copying the following hierarchy:


NSMutableArray
    NSMutableSet
        NSMutableDictionary

You'd probably want to distinguish between a deep copy (in the Cocoa sense):

NSArray
    NSSet
        NSDictionary

And a mutable deep copy:

NSMutableArray
    NSMutableSet
        NSMutableDictionary
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >How to clone a mutable dictionary (From: Steve Cronin <email@hidden>)
 >Re: How to clone a mutable dictionary (From: Graham Cox <email@hidden>)
 >Re: How to clone a mutable dictionary (From: Graham Cox <email@hidden>)
 >Re: How to clone a mutable dictionary (From: Steve Cronin <email@hidden>)
 >Re: How to clone a mutable dictionary (From: Mike Abdullah <email@hidden>)
 >Re: How to clone a mutable dictionary (From: Steve Cronin <email@hidden>)

  • Prev by Date: How to set tags for ComboBox cell items?
  • Next by Date: Re: [NSOutlineView] _outlineCell and _trackingOutlineCell vs 64-bit
  • Previous by thread: Re: How to clone a mutable dictionary
  • Next by thread: Re: How to clone a mutable dictionary
  • Index(es):
    • Date
    • Thread