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 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 otherwise. Could something like that work for you? You could have a post-processing step that iterated over the subviews/controls and set the outlets.

Having a separate nib for each prototype view is another solution, but in my case that was very inelegant because all the various prototype views I needed are much easier to edit if they are all set up in the same nib and can be related to the other controllers/windows they are used with.

hth,

Graham



On 14 Jun 2008, at 5:55 am, Torsten Curdt wrote:

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 addSubview:view];

   view = [NSUnarchiver unarchiveObjectWithData:templateView];
   [self addSubview:view];

Unfortunately (but to no big surprise) this does not set the IBOutlets.
Is there any other way but injecting the references myself?

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to