On 31 Oct. 2016, at 5:25 pm, Takaaki Naganoya <
email@hidden> wrote:
set aList to {{theName:"Sound Track", numberOfTimes:1721}, {theName:"Rock", numberOfTimes:942}}
--listed record to XML stype plist string (Serialize)
set anArray to current application's NSArray's arrayWithObject:aList
set pListData to current application's NSPropertyListSerialization's dataFromPropertyList:anArray |format|:(current application's NSPropertyListXMLFormat_v1_0) errorDescription:(missing value)
You are using a deprecated method there -- better to use this:
set aList to {{theName:"Sound Track", numberOfTimes:1721}, {theName:"Rock", numberOfTimes:942}}
--listed record to XML stype plist string (Serialize)
set pListData to current application's NSPropertyListSerialization's dataWithPropertyList:aList |format|:(current application's NSPropertyListXMLFormat_v1_0) options:0 |error|:(missing value)
set bStr to (current application's NSString's alloc()'s initWithData:pListData encoding:(current application's NSUTF8StringEncoding)) as string
--De-serialize???
set deStr to current application's NSString's stringWithString:bStr
set aDic to current application's NSPropertyListSerialization's propertyListFromData:deStr mutabilityOption:(current application's NSPropertyListMutableContainersAndLeaves) |format|:(missing value) errorDescription:(missing value) ---[__NSCFString bytes]: unrecognized selector sent to instance 0x7fe52d36aab0 error -10000
You need to pass data, and you should use the newer method:
--De-serialize???
set deStr to current application's NSString's stringWithString:bStr
set theData to deStr's dataUsingEncoding:(current application's NSUTF8StringEncoding)
set aList to current application's NSPropertyListSerialization's propertyListWithData:theData options:(current application's NSPropertyListMutableContainersAndLeaves) |format|:(missing value) |error|:(missing value)
--> {{theName:"Sound Track", numberOfTimes:1721}, {theName:"Rock", numberOfTimes:942}}--Goal (Success)
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