Can I store extra information in a data source?

I have a table where I display a list of file names. Just the names, not the full path. When a cell is selected I want to be able to go get that file and do something with it. So can I store a unseen url in the data source along with the file name? Or do I need to set up a separate data source or array?

I had a similar issue which I solved as follows. Make another column in the table, and set it’s maximum width to 0. Make the filename column a good bit longer than it needs to be, hide the vertical scrollbar, and make sure the file path column is the second one. Then, it won’t be visible or accessible, but the data will still be there.

Thanks for that. Seems like there should be a better way, but this will work fine for me now.

Sorry, but that’s awful! There is a better way!

Give your columns a name (in the Applescript part of the inspector) in Interface Builder. Now you can set up a record of default data with whatever you want in it, and add data columns to your data source:

property defaultData : {{name:"Startup Disk", path:"/"}, {name:"Applications", path:"/Applications/"}, {name:"
Shared User", path:"/Users/Shared/"}}

on will finish launching theObject -- Just before your application has finished launching
	set mainWindow to window "main"
	set tableView to table view "table" of scroll view "table" of mainWindow
	set dataSource to data source of tableView
	tell dataSource
		-- Set up our columns within the datasource (can be more than you have set up in Interface Builder)
		make new data column at end of data columns with properties {name:"name"}
		make new data column at end of data columns with properties {name:"path"}
	end tell
	
	make new default entry at end of default entries of user defaults with properties {name:"table data", contents:defaultData}
	-- Fill your table in bulk
	append dataSource with contents of default entry "table data" of user defaults
end will finish launching

Now reference your columns by name, like for instance when you want to add a row:

-- Add row to table's datasource
set currentRow to make new data row at end of data rows of dataSource
set contents of data cell "name" of currentRow to "Untitled"
set contents of data cell "path" of currentRow to ""
set selected data row of tableView to currentRow