Creating data source from a table view?

Hello All,

I’m trying to create a data source from a table view like so:

on awake from nib theObject
if name of theObject is “servers” then --NSTableView is set to servers and awake from nib is turned on
set serverDataSource to make new data source at end of data sources with properties {name:“servers”}
make new data column at end of data columns of serverDataSource with properties {name:“dns”} --data column named dns
make new data column at end of data columns of serverDataSource with properties {name:“ip”} --data column named ip

	set data source of theObject to serverDataSource
	set theRow to make new data row at end of data rows of data source "serverDataSource"
end if

end awake from nib

However, the “set data source of theObject to serverDataSource” line is giving me this error:
Can’t get data source “serverDataSource”. (-1728)

Any ideas what I am doing wrong here?
Thanks in advance!

You’ve defined your variable serverDataSource as a data source and named it “server”, but then you’ve mistakenly swapped the name and variable. This line of code is wrong:

set theRow to make new data row at end of data rows of data source "serverDataSource"

so it should be:

set theRow to make new data row at end of data rows of serverDataSource

or:

set theRow to make new data row at end of data rows of data source "server"

Tom
BareFeet