I would like to know if you could give me pointers on how to deal with plist files.
What I’m trying to do is make my app remember the transparency level, set by the user with a slidebar.
I have tried following a tutorial online but it doesnt seem to work, and I dont know why! Needless to say, I havent found a tut here that deals with plist files…
before using user defaults you have to register the key / value objects
in the awake from nib or will finish launching handler
on register_Preferences()
tell user defaults
make new default entry at end of default entries with properties {name:"transparence", contents:0.5}
register
end tell
end register_Preferences
But it’s much easier to use Cocoa bindings. This doesn’t require any code.
In Interface Builder select the slider choose Bindings in the inspector window,
enable Bind to User Defaults Controller and type transparence into the field Model Key Path
Thanks for the reply, but I’m very new at this and I’m not getting it !
Could you tell me what part of my code is wrong, and how I should use the code you posted ?
The plist file isnt even created by my app… I’m so confused !
EDIT | Alright, now the transparency slidebar does stay in the same place thanks to the binding operation you told me about. However, its just the bar that stays in the same place, the transparency is always the same when I reopen the app !
Thanks for the advice; I added “default entry” there, but it’s still the same, the transparency does not appear on opening, even though the slidebar is in the place where I left it.
What should I link to “awake from nib”, that slidebar or the main window?
awake from nib will be called before the window loads,
so this is the place to make default settings.
The registerPrefs() handler instantiates the user defaults. The default value will be ignored if the key exists in the .plist file
The chargerPrefs() reads the user defaults into the appropriate variables.
If you want to set the silder, you must do this also in the awake from nib handler
on awake from nib
registerPrefs()
chargerPrefs()
set float value of slider "transparence" of window "main" to valeur
end awake from nib