Re: A bit confused about NSView instances in Interface Builder
Re: A bit confused about NSView instances in Interface Builder
- Subject: Re: A bit confused about NSView instances in Interface Builder
- From: j o a r <email@hidden>
- Date: Sun, 1 Oct 2006 20:13:51 +0200
On 1 okt 2006, at 19.41, Fabio Mancinelli wrote:
I thought that it was a way to "factorize" part of the interface by
creating "view components" that could be reused. But I confused
because things don't work as I expect and I cannot see what is the
logic behind.
Your general line of thinking is correct.
Then I go to the main window, I drop a custom view control and I
set its custom class to A. I expected that the controls that I put
in the A design window would appear but nothing happens.
Moreover if I generate the files for A in the XCode none of the
controls I have added is present in the structure of the class.
What you've described sounds interesting, and perhaps you should
submit it to Apple as an enhancement request. However, that's not how
Interface Builder works.
So the question is: what are view instances useful for and how are
they used?
Nib files are used to hold user interface items that you want to use
in an application. Often, the root item [*] will be a window, but
that need not be the case. I will try to explain how it's used by an
example.
Consider an inspector panel - like the inspector in Interface
Builder. It has several different "sub-pages" for different things to
inspect. If you have one window that is used as a host for a wide
variety of sub-pages like this, it can make sense to break out each
such sub-panel into it's own nib file. This might even be a
requirement, for example if your application has a plugin
architecture, it might be that the plugins will provide their own sub-
panels for the inspector. In such cases, it doesn't make sense to use
a window as the root item for the sub-page nib files. Instead, you
would use a view as the root item - much like you've discovered that
you can do.
So, what you would end up with is one nib file for the inspector
window, and a lot of individual nib files for each sub-page in the
inspector. The inspector class would then, at runtime, have to load
(using the NSBundle nib loading API) each sub-page nib file as
needed, and "manually" insert their views as appropriate.
j o a r
[*] There is really no such thing as a "root item", you can have any
number of items at the root of the nib file, but that's how it's most
often laid out.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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