• 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
Reading data from plist file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reading data from plist file


  • Subject: Reading data from plist file
  • From: Jim Weisbin <email@hidden>
  • Date: Sat, 20 Feb 2016 08:00:59 -0500

I have a cocoa program that generates a plist file. I need to extract a list of numeric fileID’s from the plist, then I pass that list to Filemaker for further processing. I have that all working.

Here’s a sample of the plist:

<?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>fileIDs</key>
<array>
<integer>10593</integer>
<integer>10590</integer>
<integer>10349</integer>
<integer>3100</integer>
</array>
<key>name</key>
<string>New Playlist</string>
</dict>
</plist>

Here’s how I am extracting the list:

set f to choose file with prompt "choose plist file"
set thePListPath to POSIX path of f
tell application "System Events"
tell property list file thePListPath
tell contents
set myList to value of property list item "fileIDs"
end tell
end tell
end tell

But there is a case where the above does not work, which is when the plist has nested lists, 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>fileIDs</key>
<array>
<integer>10593</integer>
<integer>10590</integer>
<integer>10349</integer>
<integer>3100</integer>
</array>
<key>name</key>
<string>New Playlist</string>
<key>sublists</key>
<array>
<dict>
<key>fileIDs</key>
<array>
<integer>10234</integer>
<integer>10201</integer>
<integer>10207</integer>
<integer>10515</integer>
</array>
<key>name</key>
<string>New Playlist2</string>
</dict>
</array>
</dict>
</plist>

In this case, my applescript gets the top array, but obviously fails to get the “sublists” array. Any advice on how to recurse through the sublists (there could be multiple levels) would be appreciated.

Thanks.

Jim Weisbin | C.T.O. | human | 138 Fifth Avenue | 3rd Floor | New York, NY | 10011 |  

 _______________________________________________
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: Reading data from plist file
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Missing fonts problem in Illustrator
  • Next by Date: Re: Reading data from plist file
  • Previous by thread: Missing fonts problem in Illustrator
  • Next by thread: Re: Reading data from plist file
  • Index(es):
    • Date
    • Thread