AppleScriptObjC Method to Delete a List Item by Index

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
1 Like