I’m writing a really simple program that basically generates URLs and stores a history of them. I store the data in a table, and present it with a tableView. Everything works perfectly, but (you knew that but was coming, right?) there is one case that generates an error.
If I open the history, and execute the “clear history” function, the table and tableview objects both clear. However, if I scroll down the history first (even one line), then run the same “clear history” function, I get an error:
<error>
Corona Runtime Error
?:0: attempt to index field ‘?’ (a nil value)
stack traceback:
?: in function <?:1319>
(tail call): ?
history.lua:109: in function <history.lua:103>
?: in function <?:169>
</error>
Here is the code I’m executing:
<code>
for i = #historyList,1,-1 do
historyTable:deleteRows ({i},{slideUpTransitionTime = 100})
table.remove(historyList,i)
end
</code>
The error happens when the first line inside the for loop is run for the first time. The crazy thing is, if I just reload the program, with no changes to app or files, and run the program, the “clear history” works great! If I scroll, crash. If I don’t scroll, success?
Any ideas? I’ve been beating on this for weeks, because the crashes seemed so random. Finally (this week) figured out the steps to duplicate the issue, but I just don’t see a way to resolve the problem.