How to remove empty cells that I do not use in Swift


I have got a toEat array:

var toEat = ["apple"]

In addition, the user can add more fruits to the array while running the app, for example:

var toEat = ["apple", "banana"]

The array has nothing more except apple and banana, so why when I run the app I get empty cells? How can I delete it?

You can try this line of code:

self.tableView.tableFooterView = UIView(frame: CGRectZero)