Re: Binding values in a preferences window for live updates
Re: Binding values in a preferences window for live updates
- Subject: Re: Binding values in a preferences window for live updates
- From: Hal Mueller <email@hidden>
- Date: Thu, 13 Dec 2007 01:23:09 -0800
At 7:51 PM +1100 12/13/07, hinx wrote:
How to "bind each control to a preferences setting" is what I was
probably trying to ask :)
See the "User Defaults Programming Topics for Cocoa" manual. Then
read the NSUserDefaults class documentation. You'll also find "man
defaults" helpful.
You don't really want to do this. Break it into several steps.
Consider that the Model part of MVC should work without any UI.
Oh yes I think I most definitely want to do it. The whole point of the
game's preferences window is to set degrees of difficulty and view the
maximum potential score with such settings.
You don't want to do it the way you described doing it--that will
make your brain melt. The conventions of Cocoa are not just
religious pedantry, as conventions sometimes are. You really have to
follow them in order to make Cocoa work for you.
I believe your task can be accomplished, in a minimal way, by writing
only one method: one which reads the current values of the defaults
and applies your business logic to compute a maximum potential score.
You do also need to implement initial values for the defaults and
register your defaults, as described in the above-referenced manual.
Bind the output field to that maximumPotentialScore method, and
uncheck the "editable" box. Bind the parameter controls (checkboxes,
sliders, etc) to user default keys (Bind to: Shared User Defaults,
Controller Key: values, Model KeyPath: to match what you're using in
your code). I highly recommend defining global variables for the
defaults' key strings--make the compiler do the work, not you.
--
Hal Mueller email@hidden
Mobile Geographics LLC http://www.mobilegeographics.com/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden