Re: Multiple nibs
Re: Multiple nibs
- Subject: Re: Multiple nibs
- From: Nicholas Shanks <email@hidden>
- Date: Thu, 7 Feb 2002 11:53:50 +0000
On Wednesday, February 6, 2002, at 03:30 PM, Mike O'Connor wrote:
I see a lot of apps use multiple nib files, for example one for the menu
bar, and another for the main window.
Why use multiple nibs as opposed to putting everything in one big nib
The main reasons for doing this these days is speed and memory usage
(nearly the same thing on OS X). Nibs are only loaded when needed, so if
you have a large application (e.g. OmniWeb) where many a time the user is
not going to look at all the UI elements available, it decreases launch
time by doing lazy loading of the UI.
Splitting your UI into many nib files is a good thing according to every
former NeXT person I've spoken to, both within and outside Apple.
Here's the beef:
Put a window and any associated delegates, formatters, window controller
subclasses etc. into one nib file. An NSDocument subclass file will
usually contain more objects than average. You set the File Owner to an
NSWindowController subclass, which you instantiate programmatically.
Any messaging which needs to go directly to another object and not through
the controller or delegate is sent to first responder. If you don't want
it to go through the first responder, you should create a proxy action in
the controller/delegate and call that, which in the implementation uses
Cocoa's messaging web to get the message to it's eventual target.
You will find a well-planned modular application will not need much
inter-nib-object messaging, with the exception being menus (which are
greatly catered for by first responder).
Someone else can probably explain better the details of what you want, but
in two lines it boils down to:
Multiple nib files are a GoodThing for your app's efficiency.
When used properly, there is no loss in capabilities over the monolithic
nib.
Nicholas Shanks
--
http://nickshanks.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.