append data source with list containing images

Hi all,

Short question:

I can successfully set or append the contents of a data source to a list (of lists or records). It works fine if all the data cells (columns) are text, but it fails if any data cell is an image cell. Is there a way around this problem, without having to use a repeat loop (which can takes ages for a long data source)?

Detail:

I can successfully add images to a table view containing an image column, like this:

set lockedImage to load image "NSLockLockedTemplate" - could be any image file in the project
set unlockedImage to load image "NSLockUnlockedTemplate"
set myDataSource to make new data source at end in data sources
tell myDataSource
   set newDataRow to make new data row at end
   set contents of data cell "Image" in newDataRow to lockedImage
   set newDataRow to make new data row at end
   set contents of data cell "Image" in newDataRow to unlockedImage
end tell

If the data source is connected to a table view with a corresponding image cell/column, then the images appear in that column. All good so far.

and if I ask for the resulting contents of the data source, I get:

get contents of contents of myDataSource
-->
{
   {|Image|:image id 872, ...}
,   {|Image|:image id 873, ...}
}

So I should be able to cache the contents into a variable “myContents”, delete the data rows and add the contents back at the data rows, like this:

set myContents to contents of contents of myDataSource
delete every data row in myDataSource
append myDataSource with myContents

Since I’m putting back exactly what I took out, it should work. It does work perfectly if all the data cells are text, but if one is an image cell, then the script completes without error but the GUI for that window just freezes after appending the data.

I’m building a list (of records or lists) to be used as the contents of a data source of a table view. I’m trying to find a way to include images in the list, but can’t make it work. I’d like to get to the point where I can just set the contents of a data source to a prebuilt list of data, for instance:

set lockedImage to load image "NSLockLockedTemplate" - could be any image file in the project
set unlockedImage to load image "NSLockUnlockedTemplate"
set myContents to {{|Image|: lockedImage},{|Image|: unlockedImage}}
set myDataSource to make new data source at end in data sources
set contents of myDataSource to myContents

Thanks,
Tom
BareFeet