But mostly pointless. If there’s no value set, then the value is missing — which is what missing value
means, after all. In any event, this is beyond my control. I could have the code store an empty string — but as you point out, so can you, and with less effort and more control.
To be clear, you’re getting an error only because you’re trying to include missing value
in the default value
record, where the value is already effectively missing value
. But you can still do something like assign missing value to key "testProperty"
. That effectively removes the value for testProperty
, so it returns missing value
.
I can’t reproduce the crash here.
It works for whatever values you want it to — they don’t have to be properties. Because you can access values anywhere, there’s no reason you can’t use this approach instead of properties, where access to values is required in multiple handlers.
By default, the prepare storage
command also locks the actual script file (main.scpt) inside the bundle. This means top-level values (including properties) can’t be saved back after each run, and also means the script is never modified, and hence doesn’t trigger repeated authorisation dialogs for things like GUI scripting. If, for some reason, you don’t want it locked, pass false
for the write lock
parameter.
You’ll have to convince me there’s a reason. To be clear, the library doesn’t store them in a file: it passes them to the defaults system, which does the rest. So if Apple decided to change the location or file format tomorrow, it wouldn’t make any difference. (Not that they are likely, but they have changed the file format before.)
In that sense, where, how and even when they get transferred from the defaults system to disk (or vice versa) is not really your concern.