attempt to index field '_border' (a nil value) when using tableView:deleteAllRows()

I have an app I am working on that goes a few pages deep with StoryBoard, and has widget tableviews on each page. The first transition works fine, and removes the tableView properly, but the second transition gives me this error:

?:0: attempt to index field '\_border' (a nil value) stack traceback: &nbsp;&nbsp;&nbsp;&nbsp;[C]: ? &nbsp;&nbsp;&nbsp;&nbsp;?: in function 'touch' &nbsp;&nbsp;&nbsp;&nbsp;?: in function \<?:241\> &nbsp;&nbsp;&nbsp;&nbsp;?: in function \<?:218\> &nbsp;

I have my tableView:deleteAllRows() in the scene:exitScene  function on the previous page, and moving it to the scene being called doesn’t seem to help.

If I try a simple tableView:removeSelf() or a display.remove( tableView ), the simulator crashes.

Thoughts?

Looks like it happens whenever I transition into a scene that isn’t using a tableView. Perhaps I will make a tableView with a single  full screen row that displays my end content.

Your tableView isn’t by any chance a global?

I call my tableView like this 

tableView = widget.newTableView &nbsp;

not 

local tableView = widget.newTableView &nbsp;

So I think yes. Still have a slight problem distinguishing between using no prefix, the local prefix, or the _G. prefix. When I call it locally, I am unable to remove it during the scene exit. 

EDIT: When I convert to a local tableView, I get this error when I try and remove it from within either the onRowTouch function or the exitScene

attempt to index global 'tableView' (a nil value) &nbsp;

What you need to do is at the top of your storyboard scene, outside of any function is to put the line:

local tableView

By dong that, you are declaring a local variable called tableView that will be seen by the entire scene, but not by other scenes.  Then in your createScene() function you can then do:

tableView = widget.newTableView{}

and it will use the local variable you declared at the top.  From then on, no matter what function you are in within that scene, you’re accessing the proper tableView.  Since you have it global, and you’re removing it in one scene and trying to access it in another it’s causing you problems.

I did that on all the scenes, and it is still having that same error when transitioning to a scene without a tableView in it;

trying to index field '\_border' (a nil value) &nbsp;

If I remove the deleteAllRows() call from the exitScene, I don’t get the error; but the table stays on the screen. I’ve tried naming the tableViews different things, and I still get that error. I can delete the rows one at a time, but not sure what the implications of doing that long term are (i.e. moving back and forth between scenes with TV and those without)

EDIT: Also noted that while I get that message, the program continues to run. The only thing I’ve noticed is that there is a residual touch listener in place, so if I click somewhere on the scene without the TV I get a runtime error in the console. 

Looks like it happens whenever I transition into a scene that isn’t using a tableView. Perhaps I will make a tableView with a single  full screen row that displays my end content.

Your tableView isn’t by any chance a global?

I call my tableView like this 

tableView = widget.newTableView &nbsp;

not 

local tableView = widget.newTableView &nbsp;

So I think yes. Still have a slight problem distinguishing between using no prefix, the local prefix, or the _G. prefix. When I call it locally, I am unable to remove it during the scene exit. 

EDIT: When I convert to a local tableView, I get this error when I try and remove it from within either the onRowTouch function or the exitScene

attempt to index global 'tableView' (a nil value) &nbsp;

What you need to do is at the top of your storyboard scene, outside of any function is to put the line:

local tableView

By dong that, you are declaring a local variable called tableView that will be seen by the entire scene, but not by other scenes.  Then in your createScene() function you can then do:

tableView = widget.newTableView{}

and it will use the local variable you declared at the top.  From then on, no matter what function you are in within that scene, you’re accessing the proper tableView.  Since you have it global, and you’re removing it in one scene and trying to access it in another it’s causing you problems.

I did that on all the scenes, and it is still having that same error when transitioning to a scene without a tableView in it;

trying to index field '\_border' (a nil value) &nbsp;

If I remove the deleteAllRows() call from the exitScene, I don’t get the error; but the table stays on the screen. I’ve tried naming the tableViews different things, and I still get that error. I can delete the rows one at a time, but not sure what the implications of doing that long term are (i.e. moving back and forth between scenes with TV and those without)

EDIT: Also noted that while I get that message, the program continues to run. The only thing I’ve noticed is that there is a residual touch listener in place, so if I click somewhere on the scene without the TV I get a runtime error in the console. 

Still having this trouble, hoping someone has a work-around for it. So far, have not been able to remove that residual listener when I move to a page that does not have a tableView on it.

I have this problem as well. Any work-arounds would be appreciated.

Are you taking action (changing scenes) when a row in your table is touched?

I had a problem like this and what I discovered was my onRowTouch function was getting called at least twice for each tap. Once at the beginning and once at the end. I was taking action on the beginning of the touch, to remove the table and move to the next level. When you do this, that second touch event has no where to go because you’ve deleted the tableView.

The solution was to look for event.phase == “release” before removing the tabelView.

Still having this trouble, hoping someone has a work-around for it. So far, have not been able to remove that residual listener when I move to a page that does not have a tableView on it.

I have this problem as well. Any work-arounds would be appreciated.

Are you taking action (changing scenes) when a row in your table is touched?

I had a problem like this and what I discovered was my onRowTouch function was getting called at least twice for each tap. Once at the beginning and once at the end. I was taking action on the beginning of the touch, to remove the table and move to the next level. When you do this, that second touch event has no where to go because you’ve deleted the tableView.

The solution was to look for event.phase == “release” before removing the tabelView.