Last active
November 24, 2022 14:10
-
-
Save juandesant/1fb66d95d6f893b20da4d4ce4948a552 to your computer and use it in GitHub Desktop.
Enumerate keys in an AppleScript dictionary/record using the Foundation framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Based on an answer in StackOverflow | |
-- Q: https://stackoverflow.com/questions/18062494/how-to-enumerate-the-keys-and-values-of-a-record-in-applescript | |
-- A: https://stackoverflow.com/a/29545930/919692 | |
use framework "Foundation" | |
set testRecord to {b:"bbb", c:"ccc", |0|:"zero", a:"aaa", |null|:"null"} | |
set objCDictionary to current application's NSDictionary's dictionaryWithDictionary:testRecord | |
set allKeys to objCDictionary's allKeys() | |
repeat with theKey in allKeys | |
log theKey as text | |
--log (objCDictionary's valueForKey:theKey) as text | |
end repeat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment