• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How can I add items to user defaults.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How can I add items to user defaults.


  • Subject: How can I add items to user defaults.
  • From: Brian Christmas <email@hidden>
  • Date: Tue, 05 May 2015 20:51:21 +1000

G’day scripters.

I’ve got a set of existing standardUserDefaults(), and I’d like to add another item to the set, namely a date.

I’ve tried adding the item to the 'tell defaults' line, but it errors with an ‘Attempt to insert non-property list object’ error.

Trying to add the object in a separate routine also throws the same error.

I’ve tried adding the variable as a property, with the same result.

How can I add objects (a date) to  the standard user defaults please?

Regards

Santa

property startDisplayingHourlyJobsDate : current date
property displayHourlyJobsFlag : true
property theTimeStore : current date



on applicationWillFinishLaunching:aNotification
-- Insert code here to initialize your application before any files are opened
try
set p to 0
set my ShanesFord to current application's ObjectWithFords's alloc()'s init()
set p to 1
set my ftpPrintFlag to false
set p to 2
set my pathToDesktop to path to desktop
set p to 4
tell current application's NSUserDefaults to set defaults to standardUserDefaults()
set theTimeStore to current date
set time of theTimeStore to 0
set p to 5
tell defaults to registerDefaults:{saveLocalftpArchive:true, clientMaxSave:1000, trashNumber:1000, trashInc:100, clientInc:1, AutoEmptytrash:true, theUnprocessedSound:false, mailManagerDesktopFolderPathArchive:""}
set p to 6
try
tell defaults to set my saveLocalftpArchiveOnserver to objectForKey_("saveLocalftpArchive")
on error
set my saveLocalftpArchiveOnserver to false
end try
try
tell defaults to set my clientMax to objectForKey_("clientMaxSave")
on error
set my clientMax to 1000
end try
try
tell defaults to set my trashEmptyNumber to objectForKey_("trashNumber")
on error
set my trashEmptyNumber to 1000
end try
try
tell defaults to set my trashIncrement to objectForKey_("trashInc")
trashStepper's setIncrement:trashIncrement
on error
trashStepper's setIncrement:100
end try
try
tell defaults to set my clientIncrement to objectForKey_("clientInc")
on error
set my clientIncrement to 1
end try
try
tell defaults to set my AutomaticallyEmptytrash to objectForKey_("AutoEmptytrash")
on error
set my AutomaticallyEmptytrash to true
end try
try
tell defaults to set my theUnprocessedMailSound to objectForKey_("theUnprocessedSound")
on error
set my theUnprocessedMailSound to false
end try
try
set p to 7
tell defaults to set tempMailManagerDesktopFolderPath to objectForKey_("mailManagerDesktopFolderPathArchive")
tell application "Finder"
try
set my mailManagerDesktopFolderPath to (tempMailManagerDesktopFolderPath as text) as alias as text
end try
end tell
on error errmsg number errnum
try
do shell script "mkdir -p " & quoted form of POSIX path of ((my pathToDesktop) & "Mail Manager Folder" as text)
set my mailManagerDesktopFolderPath to ((my pathToDesktop & "Mail Manager Folder") as text) as alias as text
on error errmsg
tell application "System Events" to display dialog "applicationwillFinishLaunching setting Mail Manager Folder path error " & errmsg as text giving up after 40
end try
end try


try
set p to 8
tell current application's NSUserDefaults to set defaultsTwo to standardUserDefaults()
set p to 9

# This line throws an error

tell defaultsTwo to registerDefaults:{startDisplayingHourlyJobsDateStore:theTimeStore}

set p to 10
tell defaultsTwo to set my startDisplayingHourlyJobsDate to objectForKey_("startDisplayingHourlyJobsDateStore")
on error errmsg number errnum
tell application "System Events" to display dialog "applicationwillFinishLaunching error setting user defaults two" & errmsg & return & "error number " & errnum & " p = " & p as text giving up after 40
set my startDisplayingHourlyJobsDate to current date
end try

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How can I add items to user defaults.
      • From: Shane Stanley <email@hidden>
  • Next by Date: Re: How can I add items to user defaults.
  • Next by thread: Re: How can I add items to user defaults.
  • Index(es):
    • Date
    • Thread