loading a NSView packaged in a separate .nib
loading a NSView packaged in a separate .nib
- Subject: loading a NSView packaged in a separate .nib
- From: Brian Andresen <email@hidden>
- Date: Sun, 12 Dec 2004 00:21:34 -0800
My application has two document types and two corresponding window
types, each in its own .nib file. Since both windows have a
significant area that is the same, I have pulled out that area into
its own .nib file -- let's call it GizmoViewer.nib.
In each of the windows, I placed a NSCustomView and set the custom
class to GizmoViewer. In GizmoViewer's -initWithFrame: method, I have
it load the GizmoViewer.nib, do a [self release], and return the
NSView object (populated with all the right stuff) loaded out of the
.nib file.
For starters, this works great... each window type shows the common
GizmoViewer and visually it looks fine. I have a problem when it
comes to functionality though. When I load GizmoViewer.nib, I need to
connect the .nib up with an owner... and I'm not sure where to find
one! I can't use "self" because "self" (the GizmoViewer instance) is
shortly going away. I don't think I can access any enclosing view or
window because this happens in the initWithFrame: call, and I don't
believe the object could have been placed in the view hierarchy yet.
I even tried getting the current document from the
NSDocumentController, but that controller doesn't have anything yet.
(I guess that it gets the document after the window is instantiated.)
Any advice on how I can most cleanly solve this problem? To restate,
my goal is to factor out some common functionality into a NSView in
its own .nib file, and make use of it in two different window types.
Thanks,
-Brian
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden