Re: How do I save an array in plist?
Re: How do I save an array in plist?
- Subject: Re: How do I save an array in plist?
- From: Shane Stanley <email@hidden>
- Date: Fri, 30 Nov 2012 22:37:42 +1100
I've followed Shanes technique of displaying lists in tables to the letter (Page 146, I must have destroyed and renewed the bindings a dozen times), but my list still won't display.
So, I went back to the tell defaults to registerDefaults_ and seem to still have hassles with it. I added to the list, quit the app, but nothing was written to the prefs. the {saveLocalftpArchive:true bit works, but not the second statement.
should the {{theGraphClient:"Email list"}} statement have single or double brackets? Shane used it differently in two emails.
It depends on what you want to save: double if you want to save a list of records, single for a single record. It looks like you want the former. on applicationWillFinishLaunching_(aNotification) -- Insert code here to initialize your application before any files are opened tell current application's NSUserDefaults to set defaults to standardUserDefaults() tell defaults to registerDefaults_({saveLocalftpArchive:true,messagesTop:{{theGraphClient:"Email list"}}})
So at this point you're saying the key " messagesTop" is registering a list containing a single record as the factory default.
tell defaults to set SaveLocalftpArchiveOnServer to objectForKey_("saveLocalftpArchive") tell defaults to set messagesToptext to objectForKey_("messagesTop")
Now you've read the value for the key " messagesTop" into the variable messagesToptext, and what you have is either the factory default or what was written to preferences for that key last time. set end of messagesToptext to {theGraphClient:"Email list number 2"} set end of messagesToptext to {theGraphClient:"Email list number 3"} set end of messagesToptext to {theGraphClient:"Email list number 4"} # on quit, surely this should update the pref file, but it doesn't
No it shouldn't -- all you have done is modify a standard AppleScript variable. You need to modify defaults accordingly if you want the new value to be saved:
tell defaults to setObject_forKey_(messagesTopText, "messagesTop")
That stores the new value for the key, and is saved when the app quits (or earlier).
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden