###How Do I Get NS Key Value for a NSURL?
SD6 crashes on this line consistently:
set keyDataStr to (itemNSURL's resourceValuesForKeys:nsKey |error|:(missing value))
Script Debugger 6.0.4 (6A198) on macOS 10.11.6
###Test Script to Get NS Key Values
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "Foundation"
set currentApp to current application
set luKeyList to {"Date Added", "Date Modified", "Date Accessed", "Date Created", "Size Allocated", "Size", "Label Color", "Label Number", "Label Local", "Type Local", "Name", "Size Allocated Total", "Size Total", "Type [kind??]"}
set nsKeyList to {currentApp's NSURLAddedToDirectoryDateKey, currentApp's NSURLAttributeModificationDateKey, currentApp's NSURLContentAccessDateKey, currentApp's NSURLCreationDateKey, currentApp's NSURLFileAllocatedSizeKey, currentApp's NSURLFileSizeKey, currentApp's NSURLLabelColorKey, currentApp's NSURLLabelNumberKey, currentApp's NSURLLocalizedLabelKey, currentApp's NSURLLocalizedTypeDescriptionKey, currentApp's NSURLNameKey, currentApp's NSURLTotalFileAllocatedSizeKey, currentApp's NSURLTotalFileSizeKey, currentApp's NSURLTypeIdentifierKey}
set itemPath to "~/Downloads/NewFolder5.zip"
--- Expand tilde (~) in Path (if it exists) --- ## @JMichaelTX
set itemPath to (current application's NSString's stringWithString:itemPath)'s stringByExpandingTildeInPath
set itemNSURL to current application's class "NSURL"'s fileURLWithPath:itemPath
set itemKeyData to "KEY DATA FOR " & itemPath
--- GET THE NS KEY VALUES FOR THIS ITEM ---
repeat with j from 1 to length of luKeyList
set keyName to item j of luKeyList
set nsKey to getItemFromIndexList(nsKeyList, luKeyList, keyName)
### NEXT STATEMENT CRASHES SD6 WITHOUT ANY WARNING OR NOTICE ###
set keyDataStr to (itemNSURL's resourceValuesForKeys:nsKey |error|:(missing value))
## What statement do I need to get the value of the NS Key for the item?
set itemKeyData to itemKeyDate & return & keyName & ": " & keyDataStr
end repeat
--~~~~~~~~~~~~ END OF MAIN SCRIPT ~~~~~~~~~~~~~~~~~~~~~~~
on getItemFromIndexList(pMainList, pLookupList, pLookupValue)
repeat with i from 1 to length of pLookupList
--- IF ITEM FOUND, THEN RETURN CORRESPONDING ITEM IN MAIN LIST ---
if (item i of pLookupList is pLookupValue) then return (item i of pMainList)
end repeat
--- IF HERE, THEN ITEM WAS NOT FOUND, SO THROW ERROR ---
error "Item NOT Found in List: " & return & "LookupValue: >>>" & pLookupValue & "<<<"
end getItemFromIndexList