Re: 2 Cocoa Method Questions
Re: 2 Cocoa Method Questions
- Subject: Re: 2 Cocoa Method Questions
- From: Scott Anguish <email@hidden>
- Date: Thu, 16 May 2002 02:23:46 -0400
On Wednesday, May 15, 2002, at 11:58 PM, email@hidden wrote:
This is from an experienced Mac developer, who is a newbie to Cocoa...
1) When creating non-document Edit/preference style window, what is the
best
method of handling the User Interface vs Content?
<snip>
At WWDC, one apple engineer explicitly said that you should load the
User
interface when you need them (ie. opening window), and get rid of it
when the
window closes. Each window would have it's own Nib file. This makes
sense,
<snip>
The alternative to this is loading the windows on the fly (and
disposed
when done), but keeping a copy of the important data in separate
NSString,
NSNumber, etc.
<snip>
Which method would you use?
These are kind of separate questions.
Yes, it was said that you should separate out your different UI
parts into separate nibs, but it should be done as appropriate. If your
application is built around a single window, then you're not doing major
harm by keeping it in the main nib.
If you have many windows, and they're not used often, then it makes
sense to factor them out.
I would definitely not depend on the UI to hold values that are used
by the program. That isn't something that should be in the View layer
of the Model-View-Controller paradigm... Keep them in the model (which
may in the case of preferences actually be the NSUserDefaults I guess),
and have the controller (usually the owner of the preferences.nib I'd
imagine) take and set the values in the UI as appropriate.
I am using the example of User Defaults/Preferences for this method,
but it
really is talking about any non-document Window that sometimes is open,
sometimes closed, and contains editable application data.
Again.. separate out the nibs as you feel warranted (one or two
additional windows isn't going to kill the app) and keep the data
separate from the UI for storage.
2) When creating new User Interfaces, and controller objects, should
you use
Project Builder to write the template of the controller you are creating
Snip
OR
Do you use Interface Builder to create a new subclass, add the needed
outlets
and actions using the Interface Builder UI, and then create the .h & .m
file
needed for this new object? You then load and compiled these new files
using
Project Builder.
Snip
Honestly? Whichever floats your boat. If you've already got code,
then you're better off doing the addition of variables in the .h file,
and then dropping it back into IB so that you don't have to mess around
with a merge.
The books and examples (and tutorials I seen) use both method, but I am
not
sure if it is just because some were written 2 years ago, vs. recently.
Nope..
BTW.. IB and PB used to be much more savvy when dealing with each
other.. it was very cool for a while there adding outlets in IB and
having them show up in PB automatically, etc...
_______________________________________________
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.