NSUserDefaults error in applet using PrefsStorageLib

@ShaneStanley, I’m working on an applet that uses your PrefsStorageLIb. I frequently get this error when I run it from the Finder:

image

If I click Edit and run it a second time, the error (usually) goes away and the applet starts working; sometimes I have to do this a couple more times. It may or may not work reliably on subsequent runs, and I always seem to get this error after I’ve made changes to the script.

It’s a stay-open applet that uses PrefsStorageLib in on idle, on error, and another handler of my own.

The fact that that my run-it-again routine doesn’t always work, and that it’s gotten progressively less reliable as I troubleshoot this, makes me think I’m doing something wrong. Any ideas where to start looking?

I’m not sure I even need to use PrefsStorageLib — would saving to a plain text file be less complicated? All I need to do is to retain some state information between idle runs, and this may not be the best method.

I wish I could give you an explanation, but it just seems to be something that happens randomly. Some people see it frequently, others see it regularly. It just means AppleScript isn’t loading ASObjC correctly.

About the only consolation I can offer is that it doesn’t suggest you’re doing anything wrong.

Good to know it wasn’t me. :grin: But after I posted this I figured out a different way using globals — I’d thought they didn’t work with idle, but it turned out I was just doing it wrong — and that’s really more appropriate for what I’m doing anyway.