Skip navigation.
 
mlRe: loading a NSView packaged in a separate .nib
FROM : Yann Bizeul
DATE : Sun Dec 12 20:31:01 2004

The owner of your nib should be the object that declares every outlet
and actions to/from it. It is the "Controller" part of the MVC
paradigm.
Personaly, I would instanciate the controler, then in it's init method,
load the nib file with loadNibNamed: method.
Don't forget to set the owner class to your controller's class in IB.
--
Yann Bizeul - yann at tynsoe.org
Please use this e-mail when writing to me.

You can visit my projects at this address :
http://projects.tynsoe.org/
(BuddyPop - GeekTool - SSH Tunnel Manager...)
Le 12 déc. 04, à 09:21, Brian Andresen a écrit :

> 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_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
>

Related mailsAuthorDate
mlloading a NSView packaged in a separate .nib Brian Andresen Dec 12, 09:21
mlRe: loading a NSView packaged in a separate .nib Yann Bizeul Dec 12, 20:31