Re: Getting a NSView pointer from a nib
Re: Getting a NSView pointer from a nib
- Subject: Re: Getting a NSView pointer from a nib
- From: Ondra Cada <email@hidden>
- Date: Fri, 28 Apr 2006 21:39:28 +0200
Daniel,
On 28.4.2006, at 21:22, Daniel Braun wrote:
As already stated in other replies, you probably dont need to load
nib at runtime at all
Well... without loading runtime, the NIB would not be too useable,
would it?
(Sorry, could not resist :))
You probably want to have a single nib file (or one for the app,
one for the document), and let bindings do the work for you.
Agreed in that for a beginner that's best course.
Nevertheless, there are appealing reasons to load NIBs
programmatically ("runtime") on-demand, even if they are not in
loadable bundles and even if they are load only once: namely, design
cleanness, and NIB simplicity. A NIB with hundreds of objects tends
to be ugly a nightmare to maintain: much better to split the thing
into a number of smaller ones.
- (NSView *) getView
Do not use the get- prefix, unless you are returning value by reference.
Open question : how do I release all objects loaded (here I can
easily send a release to nibView, but not to e.g. controllers
present in nib. Should i add outlet to all objects in nib file so i
can release them ? (not yet tryed)
If there's a small number of objects, easiest to outlet them all.
Otherwise, you have to use a more elaborate API which gives you the
list of all the root objects (like NSNib).
You're possibly not going in the right direction. Assuming you're
familiar with Model-view-controller paradigm : you only need to
write code in the "model" part (at least for simple applications).
And unless you use CoreData, in which case you (for them simple apps)
have to write exactly zilch :)
Welcome in XXI th century :)
It's XXIst, is it not? Though English is not my native language
either :)
(I see very few case where you really want to load nib
programatically : either you want to make several instances of a
window (my case), or possibly nib is stored in a plug-in that is
loaded programatically...)
In my experience, the most usual reason is the design. Kind of, just
like you spearate your code into a number of sources though you could
write one monster .m, you separate your GUI into a number of NIBs,
though you could preapre one monster NIB.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
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