Sorry to bring this up again, I know this has been covered in previous posts, but I simply cannot get it to work, so please help!
I have source data file, where the data is separated by a semi-colon (;), like this:
Printer1;Location 1
Printer2;Location 2
Now I want to populate a table in my AppleScript app that i build using Xcode 3.2.6 when I click a button.
My code looks like this and does not work (the error is “Can’t set window 1 of «class datS» “CharDataSource” to «class datS» id 5. (-10006)”)
on clicked theObject
start progress indicator "listspinner" of window 1
set DataSource to (POSIX file "/tmp/printerlist_test.txt")
set CharData to (read DataSource)
set theDataSource to make new data source at end of data sources with properties {name:"CharDataSource"}
set data source of table view 1 of scroll view 1 of window 1 to "CharDataSource"
tell theDataSource
make new data column at end of data columns with properties {name:"printercolumn"}
make new data column at end of data columns with properties {name:"locationcolumn"}
end tell
set {TID, text item delimiters} to {text item delimiters, ";"}
tell data source "CharDataSource"
repeat with a from 1 to (count (paragraphs of CharData))
make new data row at end of data rows of theDataSource
set data source of table view 1 of scroll view 1 of window 1 to contents of theDataSource
set contents of data cell "printercolumn" of data row a of data source of table view 1 of scroll view 1 of window 1 to word 1 of paragraph a of CharData
end repeat
end tell
set text item delimiters to TID
stop progress indicator "listspinner" of window 1
end clicked
What am I doing wrong?
In the debugger console I get “Illegal NSTableView data source (CharDataSource). Must implement numberOfRowsInTableView: and tableView:objectValueForTableColumn:row:”