# Difference between tableView.deleteRowAtIndexPaths() and tableView.reloadData()

**URL:** <https://forums.kodeco.com/t/difference-between-tableview-deleterowatindexpaths-and-tableview-reloaddata/11647>\
**Category:** iOS Apprentice\
**Created:** [March 31, 2016, 11:04am UTC](https://forums.kodeco.com/t/difference-between-tableview-deleterowatindexpaths-and-tableview-reloaddata/11647 "2016-03-31T11:04:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeetendra](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jeetendra/32/74900_2.png) [@jeetendra](https://forums.kodeco.com/u/jeetendra)\
**Post date:** [March 31, 2016, 11:04am UTC](https://forums.kodeco.com/t/difference-between-tableview-deleterowatindexpaths-and-tableview-reloaddata/11647/1 "2016-03-31T11:04:14Z")

</div>

In the checklist tutorial I found that we are using below code to delete cell from tableView

`if editingStyle == UITableViewCellEditingStyle.Delete { lists.removeAtIndex(indexPath.row) let indexPaths = [indexPath] tableView.deleteRowsAtIndexPaths(indexPaths, withRowAnimation: .Automatic) }`

I am interested to know what if we simply remove the item from the list and reload the tableView? i.e  
`if editingStyle == UITableViewCellEditingStyle.Delete { lists.removeAtIndex(indexPath.row) tableView.reloadTable() }`

What are the benefit of approach 1 over approach 2?

---

<div class="post-metadata">

**Author:** ![marciokoko](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/marciokoko/32/32922_2.png) [@marciokoko](https://forums.kodeco.com/u/marciokoko)\
**Post date:** [March 31, 2016, 2:59pm UTC](https://forums.kodeco.com/t/difference-between-tableview-deleterowatindexpaths-and-tableview-reloaddata/11647/2 "2016-03-31T14:59:33Z")

</div>

> [@jeetendra](#):
>
> tableView.reloadTable()

This actually refreshes the table view to reflect the change in datasource data.

---

<div class="post-metadata">

**Author:** ![jeetendra](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jeetendra/32/74900_2.png) [@jeetendra](https://forums.kodeco.com/u/jeetendra)\
**Post date:** [March 31, 2016, 3:47pm UTC](https://forums.kodeco.com/t/difference-between-tableview-deleterowatindexpaths-and-tableview-reloaddata/11647/3 "2016-03-31T15:47:44Z")

</div>

yeah thats correct reloadTable() refreshes the table view to reflect the change in datasource, but specific to this case both reloadTable() and tableView.deleteRowsAtIndexPaths(indexPaths, withRowAnimation: .Automatic) does the same thing. So my question is which one is better and why?

---

<div class="post-metadata">

**Author:** ![hollance](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/hollance/32/109009_2.png) [@hollance](https://forums.kodeco.com/u/hollance)\
**Post date:** [March 31, 2016, 5:17pm UTC](https://forums.kodeco.com/t/difference-between-tableview-deleterowatindexpaths-and-tableview-reloaddata/11647/4 "2016-03-31T17:17:12Z")

</div>

`tableView.deleteRowsAtIndexPaths()` shows an animation for when you delete the row. You may not see this animation when the deletion happens when you go back from one screen to another, but you’ll definitely see it when it happens on the same screen. With `reloadData()` there is no animation.

---

<div class="post-metadata">

**Author:** ![jeetendra](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jeetendra/32/74900_2.png) [@jeetendra](https://forums.kodeco.com/u/jeetendra)\
**Post date:** [March 31, 2016, 5:18pm UTC](https://forums.kodeco.com/t/difference-between-tableview-deleterowatindexpaths-and-tableview-reloaddata/11647/5 "2016-03-31T17:18:35Z")

</div>

Thank you!!

Thats what I also thought.

B.R.

---

<div class="post-metadata">

**Author:** ![marciokoko](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/marciokoko/32/32922_2.png) [@marciokoko](https://forums.kodeco.com/u/marciokoko)\
**Post date:** [March 31, 2016, 5:33pm UTC](https://forums.kodeco.com/t/difference-between-tableview-deleterowatindexpaths-and-tableview-reloaddata/11647/6 "2016-03-31T17:33:34Z")

</div>

reloadRowsAtIndexPaths (which needs endUpdates to reload) returns nil when dequeueReusableCellWithIdentifier is called.  
reloadData reuses the cell which was already allocated.

Another difference is that endUpdates after reloadRowsAtIndexPaths directly calls cellForRowAtIndexPath whereas reloadData schedules the calls to cellForRowAtIndexPath at a later time so it’s not immediate.
