• 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
Re: Plist entry
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Plist entry


  • Subject: Re: Plist entry
  • From: Luther Fuller <email@hidden>
  • Date: Sat, 19 Jan 2008 07:23:37 -0600

FWIW, the rules for plist files are:
1. Read, via System Events, the entire contents of the file into a record;
2. Modify the record using record concatenation;
3. Write, via System Events, the entire record back into the plist file.


When you use Property List Editor.app to inspect the plist file, do not ever Dump to text. It's just confusing. Let System Events do that for you.

On Jan 19, 2008, at 6:55 AM, Axel Luttgens wrote:
On 19/01/08 13:09, Michael Ghilissen wrote:
Thanks  Axel.

I wish to add a second entry to the plist (e.g. numberKey 6). All my attempts can only override the existing one (in this case numberKey 5):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http:// www.apple.com/DTDs/PropertyList-1.0.dtd ">
<plist version="1.0">
<dict>
<key>numberKey</key>
<integer>5</integer>
</dict>


 <dict>
      <key>numberKey</key>
      <integer>6</integer>
  </dict>

</plist>


Hmm... this will be problematic.
In fact, a plist needs a root. With the above, you would have two roots (moreover, those roots would be indistinguishable, as they are unnamed and don't belong to an ordered set).


So, assuming you really want dictionaries, each holding a single number, you would at least need something like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http:// www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Some sub dict</key>
<dict>
<key>numberKey</key>
<integer>5</integer>
</dict>
<key>Another sub dict</key>
<dict>
<key>numberKey</key>
<string>6</string>
</dict>
</dict>
</plist>


Alternatively, you could consider an array for the root (an array being an ordered set):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http:// www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>numberKey</key>
<integer>5</integer>
</dict>
<dict>
<key>numberKey</key>
<integer>6</integer>
</dict>
</array>
</plist>


Perhaps could you a bit more precise about your needs, a plist of cookies?
Do you have entire control over the format of that plist, or do you have to comply with some requirements?


HTH,
Axel

_______________________________________________ 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
References: 
 >Plist entry (From: Michael Ghilissen <email@hidden>)
 >Re: Plist entry (From: Axel Luttgens <email@hidden>)
 >Re: Plist entry (From: Michael Ghilissen <email@hidden>)
 >Re: Plist entry (From: Axel Luttgens <email@hidden>)

  • Prev by Date: Re: Plist entry
  • Next by Date: Re: Editing Lists of LISTS
  • Previous by thread: Re: Plist entry - Oops!
  • Next by thread: Apple Professional Applications Automation Engineer Job Opening
  • Index(es):
    • Date
    • Thread