• 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 do I add single entry to .plist file, please?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do I add single entry to .plist file, please?


  • Subject: How do I add single entry to .plist file, please?
  • From: Brian Christmas <email@hidden>
  • Date: Tue, 24 Mar 2015 09:40:35 +1100

G’day scripters

I’m trying to add a single entry to a .plist file, but can’t work out how.

I presume I’d have to read in all the existing Data, and add the entry, but as the existing data is at root level, how do I add and resave it, please?

So far I’ve got this…

Regards

Santa

on saveTheGeneralData()
try
set p to 0
set thePPath to POSIX path of (((my mailManagerDesktopFolderPath) & "    General Data.plist") as text) as text
set theFlag to true
tell application "Finder"
if not (exists file (my mailManagerDesktopFolderPath & "    General Data.plist" as text)) then set theFlag to false
end tell
if theFlag then
set myDict to current application's NSDictionary's dictionaryWithContentsOfFile:(thePPath) # POsIX path
end if

# How do I add this to myDict?

set myOldMonday to current application's NSDictionary's dictionaryWithDictionary:{thePreviousMondayKey:thePreviousMonday}
set p to 7
myDict's writeToFile:thePPath atomically:true
on error errmsg number errNum
tell application "System Events" to display dialog "OAS's saveTheGeneralData " & errmsg & " p = " & p as text giving up after 40
my setEMsgs:{errNum, "mainMessagesView", "saveTheGeneralData Error " & errmsg as text, "Error Message Orange", true, "Cochin Bold", "14"}
end try
end saveTheGeneralData


on openTheGeneralData()
try
set thePPath to POSIX path of (((my mailManagerDesktopFolderPath) & "    General Data.plist") as text)
set theFlag to true
tell application "Finder"
if not (exists file (my mailManagerDesktopFolderPath & "    General Data.plist" as text)) then set theFlag to false
end tell
if theFlag then
set nowreadList to current application's NSDictionary's dictionaryWithContentsOfFile:(thePPath) # POsIX path
try
set my thePreviousMonday to nowreadList's thePreviousMondayKey
on error
my setUpMondays()
set my thePreviousMonday to (my theCurrentMonday) - days * 7
end try
end if
on error errmsg
tell application "System Events" to display dialog "openTheGeneralData " & errmsg as text giving up after 40
end try
end openTheGeneralData



 _______________________________________________
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 do I add single entry to .plist file, please?
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Can't make ... into type Unicode
  • Next by Date: Re: How do I add single entry to .plist file, please?
  • Previous by thread: Re: Can't make ... into type Unicode
  • Next by thread: Re: How do I add single entry to .plist file, please?
  • Index(es):
    • Date
    • Thread