I have a four column table in which the third column contains a checkbox. The user can select the check box and carry out a variety of operations on the selected rows, one of which is to simply delete the selected rows.
At the moment I use this which works fine but I can’t help but think there should be a better way.
on deleteAllSelected_(sender)
set theArraysRows to theArrayController's arrangedObjects()
set theCount to count of theArraysRows
-- log theCount
repeat with n from 1 to theCount
set theTableItemsObject to theArraysRows's objectAtIndex_(n - 1) as list
set therecord to item 1 of theTableItemsObject as list
set theselection to item 1 of therecord
log theselection
if theselection = true then
tell theArrayController to removeObjectAtArrangedObjectIndex_(n - 1)
end if
end repeat
end deleteAllSelected_
I can use
set aPredicate to current application's class "NSPredicate"'s predicateWithFormat_("isSelected = 1")
set theTableItems to theArraysRows's filteredArrayUsingPredicate_(aPredicate)
To identify the selected rows, but how do I get arrangedObjects Indexes? I must be missing something simple?