Re: IB Instances
Re: IB Instances
- Subject: Re: IB Instances
- From: James Bucanek <email@hidden>
- Date: Fri, 27 May 2005 11:15:59 -0700
Let's see if I can handle this one...
Theodore H. Smith wrote on Friday, May 27, 2005:
>Let's say I make some NSWindow instances with IBOutlets, and connect
>them in IB.
>
>Then let's say I make a few of these windows in my compiled app.
>
>What happens to the connections and the instances?
Instances in IB are just like instances in your application: they are physical instances (objects) of a particular class (or they will be at run-time).
When the AppKit loads a NIB, it creates one object for every instance defined in the NIB. If you have outlets, actions, and bindings defined, then those outlets, actions, and bindings get set by the AppKit once the objects are created, interconnecting them into a graph of objects.
This is what happens when you load a NIB. If you create other NSWindow objects yourself, then you have two sets of objects -- one set created when you load the NIB, and another set created progrmatically.
>Do I get multiple
>instances of everything defined in that nib, all connected to each
>other?
Yes. When you load a NIB, the AppKit will create one object for every "instance" that you've defined in the NIB. It will then connect those objects using the outlets and actions that you've defined in the NIB.
If you load the NIB multiple times (say you have a NIB defined for a document window and open multiple documents), then you get multiple sets of objects.
In a sense, a NIB is just a "script" for creating, configuring, and interconnecting a set of objects. Everytime you run the "script," you get a new set of objects (instances) of whatever you defined in the NIB.
>As always, forward me the appropriate docs, as I'm not sure where to
>look for information on instances right here.
I'd start at <http://developer.apple.com/documentation/DeveloperTools/Conceptual/IBTips/index.html>. Read the section on "What Happens when a NIB file is loaded."
--
James Bucanek <mailto:email@hidden>
_______________________________________________
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
References: | |
| >IB Instances (From: "Theodore H. Smith" <email@hidden>) |