Skip navigation.
 
mlRe: Providing replicable views in IB
FROM : Ashley Clark
DATE : Tue Oct 14 18:00:25 2008

You can implement copying of a view by archiving and immediately 
unarchiving the root view.

Something like this (written on the phone, don't expect this to parse 
correctly immediately):

-(id)copyWithZone:(NSZone *)zone {
      return [NSKeyedUnarchiver unarchiveObjectWithData:
[NSKeyedArchiver archiveDataWithRootObject:self]];
}

______
Ashley

On Oct 14, 2008, at 10:38 AM, "Matteo Manferdini" <mat.<email_removed>
> wrote:


> Hi all,
> I was trying to find a way to design a replicable view in IB.
> The behaviour I'm trying to replicate is the one of 
> NSCollectionView: it
> gets a custom view designed in IB as the prototype view and then 
> replicates
> it to display its contents. Is there an easy way to do this? Since 
> NSView
> does not implement the copy method, I don't think this is the approach
> taken.
> The hard solution would be to provide a copy method myself that 
> replicates
> all the subviews and controls (which are also subviews), but it 
> would be
> very long and difficult since for each subview all the instance 
> properties
> must be replicated, without talking about sub-subviews. Since I 
> don't want
> to go throug all this, is there an easier way to do it?
> Thank you very much.
> Cheers.
>
> Matteo Manferdini
> Pawn Software
> www.pawn-soft.com
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> 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/<email_removed>
>
> This email sent to <email_removed>
>

Related mailsAuthorDate
mlProviding replicable views in IB Matteo Manferdini Oct 14, 17:38
mlRe: Providing replicable views in IB Michael Ash Oct 14, 17:56
mlRe: Providing replicable views in IB Ashley Clark Oct 14, 18:00
mlRe: Providing replicable views in IB Matteo Manferdini Oct 15, 15:05
mlRe: Providing replicable views in IB Michael Ash Oct 15, 16:22