Preferences Plist???

I’m working on a studio app which needs to store user preferences, I use a text file created in the users preferences folder. i notices that a “real” plist was created when running the app, and some default data was stored to it. is there a way i can save my prefs to this file?

Yes. See the user defaults property in the application class.

Just a few days ago: http://bbs.applescript.net/viewtopic.php?id=13195 by gerbenzomp…

Please i’m a newbie, and don’t really understand the applescript dictionary… can someone give me a simple example of reading and writind custom prefs to/from a plist file, and how do i set the name for the plist file generated by my app?

This example reads in a single preference into a property at launch and writes it out again at quit:

property _kPreferenceName : "some preference" -- the name used in the plist (a constant)

property _somePreference : "" -- the preference value used by the application

on readPrefs() -- call from 'will finish launching' handler
	if not (exists default entry _kPreferenceName of user defaults) then
		make new default entry at end of default entries of user defaults with properties {name:_kPreferenceName, contents:_somePreference}
	end if
	set _somePreference to contents of default entry _kPreferenceName of user defaults
end readPrefs

on writePrefs() -- call from 'will quit' handler
	set contents of default entry _kPreferenceName of user defaults to _somePreference
end writePrefs

[...]

on will finish launching theObject
	[...]
	readPrefs()
	[...]
end will finish launching

on will quit theObject
	[...]
	writePrefs()
	[...]
end will quit

thanks! thats exactly what i was looking for! :smiley: