Re: duplicating views

2008-06-17 Thread Jonathan Hess
Hey Torsten - It would probably be easiest to factor your view into a separate NIB and then load that nib multiple times. If you have reasons for not doing that, you could instead take the approach you suggested below. To get your outlets to roundtrip through the keyed archiver, you need

Re: duplicating views

2008-06-17 Thread Torsten Curdt
I've just thought of another solution that might be cleaner and more obvious. If your substrate view (the one that contains the rest of the controls) is a custom view class, you need only implement the NSCoding protocol and conditionally encode the outlets yourself. Then when the view is

Re: duplicating views

2008-06-13 Thread Graham Cox
On 14 Jun 2008, at 11:10 am, Graham Cox wrote: However, I'm not relying on the view having outlets to its subviews set - in fact I don't have any outlets. Instead I embed the controls normally and find them later using their tags. This works well in my case because I'm not using the tags o

Re: duplicating views

2008-06-13 Thread Michael Ash
On Fri, Jun 13, 2008 at 4:05 PM, Torsten Curdt <[EMAIL PROTECTED]> wrote: > Hm ...factored out NIBs before. But in this case it just felt a bit award to > use this for potentially like a few hundred items. If you use NSNib, you can load the file just once, then instantiate it many times. This avoi

Re: duplicating views

2008-06-13 Thread Graham Cox
I've done exactly this in the past and it worked fine. I just checked my code to see if I was doing anything different from you - I'm not: view = [NSUnarchiver unarchiveObjectWithData:[NSArchiver archivedDataWithRootObject:prototypeView]]; However, I'm not relying on the view having outlet

Re: duplicating views

2008-06-13 Thread I. Savant
Hm ...factored out NIBs before. But in this case it just felt a bit award to use this for potentially like a few hundred items. Is your current approach working smoothly? No? Then the usual way is probably best. ;-) -- I.S. ___ Cocoa-dev mail

Re: duplicating views

2008-06-13 Thread Torsten Curdt
On Jun 13, 2008, at 13:01, I. Savant wrote: I have a NSView "template" in my nib that I am duplicating in a container view like this: Unfortunately (but to no big surprise) this does not set the IBOutlets. Is there any other way but injecting the references myself? If you have a 'reus

Re: duplicating views

2008-06-13 Thread I. Savant
> I have a NSView "template" in my nib that I am duplicating in a container > view like this: > Unfortunately (but to no big surprise) this does not set the IBOutlets. > Is there any other way but injecting the references myself? If you have a 'reusable' portion of UI, the (usually) best approa

duplicating views

2008-06-13 Thread Torsten Curdt
I have a NSView "template" in my nib that I am duplicating in a container view like this: - (void) awakeFromNib { NSView *view; NSData *templateView = [NSArchiver archivedDataWithRootObject:myView]; view = [NSUnarchiver unarchiveObjectWithData:templateView]; [self addSubvie