Is there a built in function I can use to save all contents of a table view as a text file?
Could anyone please post a snippet or something that i could use for that?
I would really appreciate it. Thanks.
Is there a built in function I can use to save all contents of a table view as a text file?
Could anyone please post a snippet or something that i could use for that?
I would really appreciate it. Thanks.
BTW, i forgot to mention, the TableView doesnt use any data sources.
This is the third similar request I’ve seen today
I’m pretty sure your table uses a data source whether you specifically created it or not. The “contents” of a table view is stored in a data source. If you don’t create it, Xcode does.
You can simply write the contents (which is a list) of the data source of the table to a file and read it back again, like this:
set myDataList to contents of data source of table view "My Table"
set dataFile to POSIX file "/Users/Shared/saved myDataList"
set writeRef to open for access dataFile with write permission
try
set eof writeRef to 0
write myDataList to writeRef
close access writeRef
on error errorMessage
close access writeRef
error errorMessage
end try
You can later read the data back from the file to a list and, if needed, dump the list back into the data source of the table by:
set myDataList to read dataFile as list
set contents of data source of table view "My Table" to myDataList
Tom
BareFeet
http://www.tandb.com.au