Hi,
I'm trying to use Late Night Software's Property List Tools scripting addition to change part of a plist but I'm getting some odd results. Maybe I've spotted a bug or maybe I'm just doing something dumb.
I have a handler that looks like this;
on alterTextProperty(theFile, theItemID, theValue)
set thePlist to read property list theFile
set |NS.string| of item theItemID of |$objects| of thePlist to theValue
store property list thePlist in theFile
end alterTextProperty
The handler's intended to change the value of certain bits of the plist.
If I compare the before and after plist using Property List Editor then they both look as I'd intended - identical apart from the bit I changed. However, the new plist is unuseable.
If I open both plists in TextWrangler and make the same change (not using AppleScript) then everything works fine.
The only clue I've managed to find is that when viewed in TextWrangler, the structure of the plist XML has changed after editing by my applescript handler.
Example of broken file (edited by my applescript);
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>$archiver</key>
<string>NSKeyedArchiver</string>
<key>$objects</key>
<array>
<string>$null</string>
<dict>
<key>BottomMargin</key>
<real>18</real>
Example of good file (before editing);
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>$archiver</key>
<string>NSKeyedArchiver</string>
<key>$objects</key>
<array>
<string>$null</string>
<dict>
<key>$class</key>
<dict>
<key>CF$UID</key>
<integer>27</integer>
</dict>
<key>BottomMargin</key>
<real>18</real>
Am I doing something dumb or is the scripting addition broken? Is there an alternative method? Any suggestions appreciated!
Regards
Rob