Having the damnedest time with table views...

Using Apple’s “Table” → “with data source” example project as a reference, I am trying to build a project with a table. However I keep getting the error:


Below is the code I am using. It is a virtual copy-paste from Apple’s example (which works just fine of course) The UI is just a two column table and a button.

What in the heck am I doing wrong?


property filesDataSource : null

on will open theObject
	
	set filesDataSource to data source of table view "file_list" of scroll view "file_list" of theObject
	
	tell filesDataSource
		make new data column at the end of the data columns with properties {name:"file_path"}
		make new data column at the end of the data columns with properties {name:"file_count"}
	end tell
	
end will open

on clicked theObject
	
	if name of theObject is equal to "button" then
		--Error seems to be caused by this next statement.
		set theRow to make new data row at the end of the data rows of filesDataSource
		
		tell window of theObject
			set contents of data cell "file_path" of theRow to "Some text"
			set contents of data cell "file_count" of theRow to "Some different text"
		end tell
	end if
	
end clicked

Thanks!!

OK, well I solved my problem by basically ditching everything and changing to a method I saw somewhere else. But I would still very much like to learn why my previous code failed, and if that method is any better or worse than the below code:


on awake from nib theObject
	if name of theObject is "file_table" then
		set filesDataSource to make new data source at the end of data sources with properties {name:"file_list"}
		make new data column at end of data columns of filesDataSource with properties {name:"file_path"}
		make new data column at end of data columns of filesDataSource with properties {name:"file_count"}
		set data source of theObject to filesDataSource
	end if
end awake from nib

on clicked theObject
	if name of theObject is equal to "button" then	append data source "file_list" with {{"Some Text", "Some Different Text"}}
end clicked

Thanks!!