Re: 2 Cocoa Method Questions
Re: 2 Cocoa Method Questions
- Subject: Re: 2 Cocoa Method Questions
- From: "Erik J. Barzeski" <email@hidden>
- Date: Thu, 16 May 2002 11:47:11 -0400
Hi,
On 5/16/02 10:32am, Scott Anguish <email@hidden> wrote:
>
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.
The way I've found myself doing it - and y'all can tell me if it's stupid or
what - is this:
When the prefs window opens, read the defaults, set the UI values. When
"Cancel" is clicked or the window is closed: dispose of the window. The next
time they choose to open it, the values will be reset if they made changes
(reset to the user defaults, I mean, the "model" of the preferences).
The only time I write to the prefs is when they choose the "Apply" or "Save"
button, depending on how your prefs dialog is set up... Then I write to
current UI values to the defaults. The next time the window opens, again,
the values are read.
This, however, doesn't apply to things like inspectors or things that aren't
preferences, I suppose. If a document has preferences, they typically follow
the same 'save' convention as the document itself: save when the document
saves. However, there are all sorts of variants once you leave
application-wide preferences, and if this was the intent of your original
question, I apologize for the first three off-topic paragraphs. :)
--
Kindest regards,
Erik J. Barzeski
Life is like a box of chocolates - Sometimes you run across a nut.
*******************************************************************
Email: erik@(anything below)
AIM: iacas ICQ: 8186546
http://barzeski.com/ http://weims.net/
http://techstra.net/ http://cocoadevcentral.com/
http://soundsetcentral.com/ http://applescriptcentral.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.