Instance Method

beginUpdates()

Begins a series of method calls that insert, delete, or select rows and sections of the table view.

Declaration

func beginUpdates()

Discussion

Use the performBatchUpdates(_:completion:) method instead of this one whenever possible.

Call this method if you want subsequent insertions, deletion, and selection operations (for example, cellForRow(at:) and indexPathsForVisibleRows) to be animated simultaneously. You can also use this method followed by the endUpdates() method to animate the change in the row heights without reloading the cell. This group of methods must conclude with an invocation of endUpdates(). These method pairs can be nested. If you do not make the insertion, deletion, and selection calls inside this block, table attributes such as row count might become invalid. You should not call reloadData() within the group; if you call this method within the group, you must perform any animations yourself.

See Also

Inserting, Deleting, and Moving Rows and Sections

func insertRows(at: [IndexPath], with: UITableView.RowAnimation)

Inserts rows in the table view at the locations identified by an array of index paths, with an option to animate the insertion.

func deleteRows(at: [IndexPath], with: UITableView.RowAnimation)

Deletes the rows specified by an array of index paths, with an option to animate the deletion.

func moveRow(at: IndexPath, to: IndexPath)

Moves the row at a specified location to a destination location.

func insertSections(IndexSet, with: UITableView.RowAnimation)

Inserts one or more sections in the table view, with an option to animate the insertion.

func deleteSections(IndexSet, with: UITableView.RowAnimation)

Deletes one or more sections in the table view, with an option to animate the deletion.

func moveSection(Int, toSection: Int)

Moves a section to a new location in the table view.

func performBatchUpdates((() -> Void)?, completion: ((Bool) -> Void)? = nil)

Animates multiple insert, delete, reload, and move operations as a group.

func endUpdates()

Concludes a series of method calls that insert, delete, select, or reload rows and sections of the table view.