binding Shared User Defaults

Just a quick question.

Has anyone tried to bind a checkbox, or other element, to shared user defaults? This worked fine in ASS but I can’t get it to work. maybe some setting is off. It is nice because you don’t need any defaults code.

I selected

Bind
Shared User defaults
Controller Key = Values
MKP = defaults key name
updates continuously

?

Thanks, rob

Hi,

Dis you create missing value properties in your script to bind them to your UI elements values? This is required.

And also, I found out that this does not set default user defaults, only if you change the state you defined in IB will it be saved in the user defaults at quit with this bit of code:

First, make a reference to the NSUserDefaults class:

property NSUserDefaults : class "NSUserDefaults" of current application

Then use this in your “applicationShouldTerminate_” handler:

tell NSUserDefaults
			tell its standardUserDefaults()
				its setObject_forKey_(aValue, "aValue")
				its setObject_forKey_(someOtherValue, "someOtherValue")
			end tell
		end tell

I know that you have to change the setObject_forKey_ if it’s a boolean, string, dictionary, etc. Some previous posts discussed this before…

Hope this answers your question…

Model: MacBookPro2,2
Browser: Safari 531.9
Operating System: Mac OS X (10.6)

That is binding the UI element to the property in your script, and to change it by changing the property. But I am asking about binding the UI element to Shared User Defaults in the bindings pane, not to the instance of a script class. I did this with user defaults in ASS and it means the value of the checkbox would be automatically saved to defaults and retained, without code. It doesn’t seem to work though here.

You can not bind it to User Defaults and to the class property - only one value binding allowed.

Anyone try this yet?

Rob

I’m not sure what your problem is; it works fine here…

It works now. I started over since a lot of things seemed buggy. I kept getting “uncaught exceptions” errors.

Thanks , Rob