Deleting lines in a TableView

In my app, there is a TableView that any row of it contains a title and a “delete” btn, which I want to show and hide when clicking “Edit” button. That’s works fine, but when I remove a row and then “hiding” the Delete button. there is an error that goes like this:

attempt to index field '?' (a nil value) stack traceback: ?:in function \<?:296\> (tail call):? recipiesList.lua:30: in function '\_onRelease' ?: in function '?' ?: in function \<?:424\> ?: in function \<?:218\>

This is the code that remove the delete buttons:

[lua]local numRows = listTableView:getNumRows( )
print( “numRows:”, numRows )
for i=1, numRows do
local row = listTableView:getRowAtIndex( i )
print( “row:”, row.params.title )
if row and (not row.isCategory) then
transition.to( row.deleteBtn, { x = -20 } )
transition.to( row.rowTitle, { x = 0 } )
end
end[/lua]

Any Help?

Most likely you are trying to hide the delete button for a row that has (or is about to be) deleted.

It’s possible that the tableView widget does it’s deleting via an event sent to self, in which case listTableView:getNumRows may overstate the count by 1 (or how many deleted).

If you post more code, it will be easier to see what’s happening…

D

Most likely you are trying to hide the delete button for a row that has (or is about to be) deleted.

It’s possible that the tableView widget does it’s deleting via an event sent to self, in which case listTableView:getNumRows may overstate the count by 1 (or how many deleted).

If you post more code, it will be easier to see what’s happening…

D