Update NSUserDefaults

When developing an app, I need some times to change “manually” a key-value in the preference file.
This modification will not be available until a system restart because NSUserDefaults are cached.

Numerous posts on the web are saying that we can use the synchronize method.
Apple documentation says this method is unnecessary and shouldn't be used.
In fact, the method has no effect on my system (still High Sierra!!).

Shall I use the shell command: do shell script "defaults read " & bundleID?
Or is there another way to do this in AppleScriptObjC?

Is there some reason you’re not using NSUserDefaults?

Because in some case it’s easier for me to open the plist file and modify it rather than writing the code to perform the change. It’s just a habit. And if it can save me some typing…


A good one to break…

1 Like