Re: How to open a second window?
Re: How to open a second window?
- Subject: Re: How to open a second window?
- From: "Erik M. Buck" <email@hidden>
- Date: Fri, 10 Aug 2001 20:47:08 -0500
Set the File's Owner class to InfoWindowController in the nib that contains
the info window.
Make the connection from File's Owner outlet to the info window.
Have your main controller create an instance of InfoWindowController. Have
the instance of InfoWindowController load the nib that contains the info
window specifying that the InfoWindowController instance is the owner. The
outlet in the InfoWindowController instance will automatically get connected
to the info window instantiated in the nib when the nib is loaded.
RTFM "File's Owner"
http://www.oreilly.com/catalog/learncocoa/apple/ch10.html
http://www.oreilly.com/catalog/learncocoa/apple/ch06.html
http://www.mactech.com/articles/mactech/Vol.13/13.11/Nov97-GettingStarted/
http://www.mactech.com/articles/mactech/Vol.13/13.05/OpenStepDemonstration/
http://www.channelu.com/NeXT/NeXTStep/3.3/nd/DevTools/NewInterfaceBuilder/06
_MultipleNibs.htmld/
http://www.aaa-plus.com/joy/docs/Tutorial.JavaScript/Output-Next/Tutorial/Ti
psAndTricks.html
http://www.google.com/search?as_q=File's+Owner+nib&num=100&btnG=Google+Sea
rch&as_epq=&as_oq=&as_eq=&lr=&as_qdr=all&as_occt=any&as_dt=i&as_sitesearch=&
safe=off
<Quote>
About File's Owner
Every nib file has one owner, represented by the File's Owner icon in a nib
file window. The owner is an object, external to the nib file, that relays
messages between the objects unarchived from the nib file and the other
objects in your application.
You specify a file's owner programmatically, in the second argument of
NSBundle's loadNibNamed:owner:. The File's Owner icon in Interface Builder
is a "proxy" object for that owner. Although you can assign owners to this
object in Interface Builder, this doesn't necessarily guarantee anything
about the file's real owner.
In the main nib file, File's Owner always represents NSApp, the global
NSApplication constant. The main nib file is created automatically when you
create an application project; it is loaded when an application is launched.
Nib files other than the main nib file--auxiliary nib files--contain objects
and resources that an application may load only when it needs them (for
example, an Info panel). You must specify the owner of auxiliary nib files.
You can determine or change the class of the current nib file's owner in
Interface Builder by selecting the File's Owner icon in the nib file window
and then displaying the Custom Class Info window. You'll get to practice
this technique when you learn how to create multidocument applications in
Chapter 11, "Cocoa's Multiple-DocumentArchitecture".
<End-Quote>
<Quote>
Nib Files
A nib file is an archive of object instances generated by Interface Builder.
Unlike the product of many user interface building systems, a nib file is
not generated code; it is a true object that has been specially encoded and
stored on disk. The objects in the nib file are created and manipulated
using Interface Builder's graphical tools.
Nib files typically package a group of related user interface objects and
supporting resources, along with information about how the objects are
related--both to one another and to other objects in your application. Every
application with a graphical user interface has at least one nib file that
is loaded automatically when the application is launched. The main nib file
typically contains the application menu, while auxiliary nib files contain
the application windows with their associated user interface objects. An
important advantage of splitting an application's interface into several nib
files is that portions of the user interface may be loaded only when needed.
A nib file contains one or more of the following:
a.. Archived objects. These objects are also known in object-oriented
terminology as "flattened" or "serialized" objects, meaning that the object
has been encoded in such a way that it can be saved to disk (or transmitted
over a network connection) and later restored in memory. Archived objects
contain information such as their size, location, and position in the object
hierarchy. At the top of the hierarchy of archived objects is the file's
owner object, a proxy object that points to the actual object that owns the
nib file (typically the one that loaded the nib file from disk).
b.. Class references. Interface Builder can store the details of Cocoa
objects and objects that you make into a palette, but it does not know how
to archive instances of your custom classes, since it doesn't have access to
the code. For these classes, Interface Builder stores a proxy object to
which it attaches class information.
c.. Connection information. Interface Builder creates special connector
objects to store information about how objects within the object hierarchy
are interconnected. When you save the document, connector objects are
archived in the nib file along with the objects they connect.
Outlets
An outlet is an instance variable that contains a reference to another
object. An object can communicate with other objects in an application by
sending messages to them through outlets, as shown in Figure 6-5.
Figure 6.5. Using an outlet to send a message
An outlet can reference any object in an application: user interface objects
such as text fields and buttons, windows and dialog boxes, instances of
custom classes, and even the application object itself. What distinguishes
outlets from other instance variables is their relationship to Interface
Builder.
Interface Builder can "recognize" an outlet declaration in a header file,
allowing you to set its value by drawing connection lines between objects.
Specifying these relationships between objects in Interface Builder saves
you from having to writeinitialization code by hand. There are ways other
than outlets to reference objects in an application, but outlets and
Interface Builder's facility for initializing them are a great convenience.
<End-Quote>
[demime 0.98b removed an attachment of type application/octet-stream which had a name of LCoc_0605.gif]