Skip to content

Instantly share code, notes, and snippets.

@juandesant
Last active November 24, 2022 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juandesant/1fb66d95d6f893b20da4d4ce4948a552 to your computer and use it in GitHub Desktop.
Save juandesant/1fb66d95d6f893b20da4d4ce4948a552 to your computer and use it in GitHub Desktop.
Enumerate keys in an AppleScript dictionary/record using the Foundation framework
-- 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