Register user defaults for a checkbox?

I’m registering some user defaults in my application as follows:

tell defaults to registerDefaults_({tagDestination:“Overwrite existing comments”, genreStartDelim:“(”, genreEndDelim:“)”, genreDelimiterEnabled:“0”}}

genreDelimiterEnabled is a checkbox, but using the value of 0 doesn’t seem to work.

I was just wondering what the value should be registered as?

And better yet where are these defaults that are written documented?

You’re using the string “0” – use the number 0 instead.

Ok. How to I know which type a particular object will be writing for it’s defaults?

You look it up in the documentation. In the case of a button, what you are storing is its state, and the -state method says it returns an integer.

Whenever you put something in quotes like that, it will be a string/text.

“0” is not the same as 0


set anExample to "0" -- string/text
set anExample to 0 -- number/integer

I recognize the difference between a string and an integer :slight_smile:

What I am having trouble with is navigating the Apple documentation to a place where it shows which method is called on an object when it’s value is to be stored in the Shared User Defaults.

Just think in terms of the method you would use if you were doing it manually.