My thinking is that you have an array that contains, say, 20 items and your tableView is accessing an index that is outside the range of array indexes such as the 21st row which does not exist.
Have you placed any breakpoints in your code to try and identify at what point the code accesses an array index out of range?
It might help if you paste your code for your ViewController that contains the tableView.
Paste your code in as text, rather than providing a screenshot.
To format the code nicely, place 3 back-ticks ``` on the line above your code and 3 back-ticks ``` on the line below your code. Like this:
```
Code goes here
```
The 3 back-ticks must be the ONLY characters on the line. The back-tick character is located on the same keyboard key as the tilde character ~ (which is located below the Esc key).
Alternatively after you paste in your code, select that code block and click the </> button on the toolbar. This does the same thing as manually typing the 3 back ticks on the line above and below your code.
This also makes it easier for anyone assisting as they can copy the code and carry out some testing.
I don’t see an array of items defined anywhere in your code.
You have a whole lot of buttons created so I am curious to know what you are trying to do. Can you explain what you want to do and I’ll try to give you some guidance on how you should go about coding it.
So this is basically a menu item. When each button is clicked it will direct it to a page that is corresponding to that button. For example when apple is clicked it will take it to the apple page. (hope I made sense)
So do you want the list of fruit to appear in a table such that you tap on a row and it presents you a screen that has more details about that item of fruit?
I just got a chance to see it. So instead of making each one a button, I would list all as var allFruit and then make the count in a way that it returns as the amount of fruits I had listed under var allFruit