xCode Tables

I’m having a hard time understanding the table view in xCode, and of course I keep finding situations where I want to use it. Here is the code I’m playing with…


set myList to {"TEST1", "TEST2", "TEST3", "ABC", "GHI", "DEF"}
set theDataSource to make new data source at end of data sources with properties {name:"fileNames"}
tell theDataSource
	make new data column at end of data columns of theDataSource with properties {name:"fileName", sort order:ascending}
	set sort column of theDataSource to data column "fileName" of theDataSource
end tell
	
set data source of table view "Applications" of scroll view "Applications" of window "main" to theDataSource
append theDataSource with myList
	
make new data column at end of data columns of theDataSource with properties {name:"fileName"}

I can’t figure out in this code how you determine which column the data should go in. It is currently putting the data into my first column.

Any help would be great!
Dave

You have redundant references in your code. You use “of theDataSource” in a “tell theDataSource” block and this won’t work. Try the following code (if you get an error, you probably haven’t named the scroll view and table view or you are calling this from within some other block that causes problems):

set myList to {"TEST1", "TEST2", "TEST3", "ABC", "GHI", "DEF"}
set theTable to table view "Applications" of scroll view "Applications" of window "main"
set theDataSource to make new data source at end of data sources
set data source of theTable to theDataSource
try
	set use sort indicators of theTable to true
end
tell theDataSource
	make new data column at end of data columns with properties {name:"fileName", sort order:ascending}
	set sort column to data column "fileName"
	append with myList
	set localized sort to true
	set sorted to true
end tell

Jon