I’ve just released a Script Library for storing preferences and persistent values. This gets around the problem where applets cannot retain property values between launches because they are codesigned, or locked to avoid repeated authorization dialogs.
PrefsStorageLib takes advantage of the system-provided user defaults system, and values are reflected in the relevant property list (.plist) files in a user’s ~/Library/Preferences folder. It requires macOS 10.11 or later. You can get it here:
https://www.macosxautomation.com/applescript/apps/Script_Libs.html#PrefsStorageLib
I am using the library to save values as preference plist of an Applet in my user Preferences folder.
Is it possible to pinpoint the preference file such as:
set pathToPref to (path to preferences) -- here I would like to insert the path for the file
tell application "Finder" to open pathToPref
But instead to open the Preferences folder, I would like to open/reveal the preference files for the applet.
Thanks !
You can use:
set pathToPref to (path to preferences as text) & my id & ".plist"
But there’s no guarantee on when any changes you make to values will be written to file. The canonical values are held by the defaults system in memory, and it decides when to back them up to disk. It’s usually very quick these days, but it’s not instantaneous.