copyWithZone archive/unarchive
copyWithZone archive/unarchive
- Subject: copyWithZone archive/unarchive
- From: Trygve Inda <email@hidden>
- Date: Thu, 29 Jan 2015 21:44:12 -0800
- Thread-topic: copyWithZone archive/unarchive
I have a custom class (MyCustomClass) and within another class I need to
have MyCustomClass be a property whereby I make a copy (vs retaining).
MyCustomClass is quite complex and so I was considering using:
-(id)copyWithZone:(NSZone *)zone
{
MyCustomClass* copy = [NSKeyedUnarchiver
unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:self]];
return (copy);
}
This will of course incur a performance hit for the archiving but in my case
it is not very significant. However, naming conventions expect copy to not
be autoreleased so should the above really be:
return ([copy retain]);
?
_______________________________________________
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