I wrote a -deepCopy method as part of a protocol on the common collection 
classes. It does a respondsToSelector: and calls -copy if it doesn't. So as 
long as my collection views cover all collection classes to create a new 
NSArray etc. containing copies of the same objects, it mostly works. Downsides: 
This will make immutable copies of mutable objects (if you called -mutableCopy 
where available, you might do the reverse), and you need to be careful that you 
don't miss adding -deepCopy to a class.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de

On Feb 14, 2013, at 3:07 AM, James Maxwell <jbmaxw...@rubato-music.com> wrote:

> I've run into a situation where I really need a deep copy of an object. I've 
> implemented this using Apple's recommended approach with 
> NSKeyedArchiver/Unarchiver, and it's nice, simple, and functional. But it's 
> also pretty darn slow -- as in a clear, subjectively apparent performance hit.
> Has anybody had to find a way around this, and if so, what did you do? Or if 
> anybody just has a nice, creative thought about another way of doing it, I'd 
> love to hear about it.
> 
> The object(s) being copied are custom classes, and there's a chance I may be 
> able to get away with copying only certain properties (i.e., rather than 
> archiving the entire graph from the root object), so I'll look into making a 
> "deepCopy" method that's more selective. But I'd appreciate any thoughts in 
> the meantime.
> 
> Thanks in advance.
> 
> J.
> _______________________________________________
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/witness.of.teachtext%40gmx.net
> 
> This email sent to witness.of.teacht...@gmx.net


_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to