Need help formatting array to insert into table.

G’day folks.

I must be formatting the following incorrectly, as it logs errors when trying to insert the data into a 5 column table.

The blocked out code works fine, just my array is faulty, but it doesn’t generate an error.

Any body know what I’m doing wrong please?

Regards

Santa


set theMainData to {}
		repeat with x from 1 to count of theClientFinalList
			set ClientColumn to {}
			set end of ClientColumn to "|Client|:" & "\"" & item x of theClientFinalList & "\""
			set end of ClientColumn to "|AverageTime|:" & item x of TheAverageList
			set end of ClientColumn to "|MinTime|:" & item x of TheMinList
			set end of ClientColumn to "|MaxTime|:" & item x of TheMaxList
			set end of ClientColumn to "|NumberJobs|:" & item x of TheCountList
			set end of theMainData to ClientColumn
		end repeat
		display dialog item 1 of theMainData as text
		display dialog item 1 of item 1 of theMainData as text
		log theMainData
		try
			set theDataSource to NSMutableArray's alloc()'s init()
			theDataSource's addObjectsFromArray_(theMainData)
			aTableView's reloadData()
		on error errmsg
			display dialog errmsg
		end try
		(*set theDataSource to NSMutableArray's alloc()'s init()
		set thedata to {{|Client|:"A Christmas Carol", |AverageTime|:128, MinTime:1, MaxTime:1, NumberJobs:9}, {Client:"The Adventures of Huckleberry Finn", AverageTime:140, MinTime:1, MaxTime:1, NumberJobs:9}, {Client:"The Adventures of Tom Sawyer", AverageTime:131, MinTime:0, MaxTime:1, NumberJobs:9}, {Client:"War and Peace", AverageTime:168, MinTime:0, MaxTime:1, NumberJobs:9}}
		theDataSource's addObjectsFromArray_(thedata)
		aTableView's reloadData()*)

You’re doing to much work. All you need to do is build a normal AS list of records and use that, something like:

set theMainData to {}
repeat with x from 1 to count of theClientFinalList
	set end of theMainData to {client:"\"" & item x of theClientFinalList & "\"", AverageTime:item x of TheAverageList, MinTime:item x of TheMinList,...}
end repeat
theDataSource's addObjectsFromArray_(theMainData)
aTableView's reloadData()

G’day Shane.

Thanks, that works a treat.

Regards

Santa