Populate pasteboard contents with data values?

I have a prepare drag handler that copies the data values of a table view/data source. The table displays POSIX file paths, and my code works well but becomes very slow when the table has many entries (I’ve been testing with about 850 rows).

The table is sorted.

Here is the loop that populates the pasteboard in the prepare drag handler:

on prepare table drag theObject drag rows dragRows pasteboard thePasteboard
...
set theData to {}
repeat with i in dragRows
    set selected row of theObject to i
    copy (contents of data cell 1 of selected data row of theObject as string) to end of theData
end repeat
set content of thePasteboard to contents of theData
...
return true
end prepare table drag

Once the pasteboard content is ready I’m processing it in a “drop handler” in another table.
I’ve tried using a script object and creating properties as references to theObject, theData, and content of thePasteboard without success.

I’ve been thinking that there could be a better way than actually copying the data into the pasteboard, that I should use the dragRows constructively in the table drop handler, but haven’t been successful with that so far.

Any advice is appreciated, many thanks in advance.

-John

I’ve continued researching this and it’s starting to look like one of the great mysteries of data sources. Still looking…

Inspired by my own post, I read the Terminology Guide again and discovered the sorted data rows property of data sources.

A few minutes later and I think I have a solution:


	set sortedRows to sorted data rows of theDataSource
	
	set theData to {}
	repeat with i in dragRows
		set rowID to item i of sortedRows
		copy contents of data cell 1 of rowID as string to end of theData
	end repeat
	
	set content of thePasteboard to theData

Yay!