Re: Confusion with copyWithZone and Archiving
Re: Confusion with copyWithZone and Archiving
- Subject: Re: Confusion with copyWithZone and Archiving
- From: Graham Cox <email@hidden>
- Date: Tue, 01 Mar 2016 17:01:02 +1100
> On 1 Mar 2016, at 10:24 AM, Doug Hill <email@hidden> wrote:
>
> Given the amount of private implementation in NSView, my guess is that copying an NSView yourself without super support would be difficult/impossible in practice. However, I would be interested in others with more information to give an opinion.
Agreed, and the need to copy something designed to be uncopyable in general may be a code smell. It might be a case that the view in question should ‘have a’ whatever copyable thingamajig instead of being subclassed to ‘be a’ thingamajig. In the few cases where copying views is legitimate (I can think of one case where I programatically created a stack of views based on a series of templates - but that was before NSViewController existed and that would probably be the right solution now) you can use the archive/dearchive solution to copy a view. Alternatively, it might be enough to create a view as part of a copy and only use basic properties such as its frame to define the copied one. If it has subviews though… ugh.
G.
_______________________________________________
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