Hey Folks,
I was thinking there was a straightforward method to remove an item from a list given its index, but I’m not finding anything.
Does anyone have a good example?
TIA.
-Chris
Hey Folks,
I was thinking there was a straightforward method to remove an item from a list given its index, but I’m not finding anything.
Does anyone have a good example?
TIA.
-Chris
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
set theList to {1, 2, 3, 4, 5}
set theList to current application's NSMutableArray's arrayWithArray:theList
theList's removeObjectAtIndex:2 -- zero-based index
return theList as list
Hey Shane,
After some looking I can’t seem to find a similar routine that would remove the list item by name.
How would one do that?
TIA.
-Chris
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
set theList to {"One", "Two", "Three", "Four", "Five"}
set theList to current application's NSMutableArray's arrayWithArray:theList
theList's removeObject:"Two"
return theList as list
Many thanks for the quick response!