Re: Providing replicable views in IB
Re: Providing replicable views in IB
- Subject: Re: Providing replicable views in IB
- From: "Matteo Manferdini" <email@hidden>
- Date: Wed, 15 Oct 2008 15:05:08 +0200
Thank you very much!
I did not think about the crappy way becase it *is* an unnatural way of
doing things. By the way, how do you know NSCollectionView does it that way?
Where do you collect such detailed informations?
I did not know the second one. Thank you.
Cheers.
On Tue, Oct 14, 2008 at 5:56 PM, Michael Ash <email@hidden> wrote:
> On Tue, Oct 14, 2008 at 11:38 AM, Matteo Manferdini
> <email@hidden> 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.
>
> There are basically two ways to do it.
>
> One way, the crappy way, which NSCollectionView uses, is to use
> NSCoder. You'll note that NSView does not conform to NSCopying but it
> does conform to NSCoding. So the easy way to "copy" a view is to
> serialize and then deserialize it. This is crappy because it's kind of
> unnatural, requires some extra work to maintain external connections,
> and in general is just sort of clunky.
>
> The other way, which I prefer, is to simply put the view in question
> into a separate nib. Then just load the nib any time you want a new
> view.
>
> Mike
> _______________________________________________
>
> 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
>
_______________________________________________
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