Code assistance

I have a table view with single-column rows in it, and my code to delete rows from the data source looks like this:


	set selectedRows to selected data rows of theTableView
	
	if (count of selectedRows) > 0 then
		repeat with i in selectedRows
			delete i
		end repeat
	else
		delete data rows of theDataSource
	end if
	
	set update views of theDataSource to true

This works fine logically - if no rows are selected, all the rows are deleted. If any rows are selected, only those selected rows are deleted. The problem is when all the rows are selected - it is very slow above 500 rows or so.

What should I do to speed up the delete loop? I’ve been reading about using call method and reading about NSTableView and its methods, but don’t have a clear solution yet.

I’ve tried creating a script property as a reference to the selectedRows list and it didn’t seem to help. My grasp of syntax issues is sometimes poor and hope more experienced folks can look at it and see a solution.

Thanks,

-John