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 (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com