Coerce NSDictionary to AS Record

Hi,

when i read a plist file from disk with:

tell current application’s NSDictionary
set myDict to dictionaryWithContentsOfFile_(“/Users/adminosx/Desktop/example.plist”)
end tell

the myDict contains something like AS Records.
But when I access to the fields I have to coerce as string or as integer… every single field.
Is possible to coerce all myDict to AS record with:

set myDict to myDict as record

Any limitations about this conversion? From my test all seems to works good.

Ame

Model: iMac
Browser: Safari 536.26.17
Operating System: Mac OS X (10.8)

Hi,

coercing a NSDictionary to AppleScript record is fine.
NSString, NSNumber, NSArray and NSDictionary are coerced to their AppleScript equivalents
Consider that NSDate is not coerced to an AppleScript date object.

Indeed. Here are a couple of handlers for that conversion:

on makeNSDateFrom_(theASDate)
	set refDate to date "Friday, 1 January 1904 0:00:00 +1000" as date
	set theDiff to theASDate - refDate - 3.061152E+9 - (time to GMT) + (current application's NSTimeZone's localTimeZone()'s daylightSavingTimeOffset()) as real
	set newDate to current application's NSDate's dateWithTimeIntervalSinceReferenceDate_(theDiff)
	return newDate
end makeNSDateFrom_

on makeASDateFrom_(theNSDate)
	set refDate to date "Friday, 1 January 1904 0:00:00 +1000" as date
	set theDiff to theNSDate's timeIntervalSinceReferenceDate()
	return refDate + theDiff div 1 - 3.061152E+9 + (time to GMT) - (current application's NSTimeZone's localTimeZone()'s daylightSavingTimeOffset()) as real
end makeASDateFrom_