Author Topic: How to clear all the cells from a table view  (Read 1634 times)

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
How to clear all the cells from a table view
« on: August 04, 2014, 05:42:01 PM »
To clear all the cells from a table view, first remove all the objects from the table view's data source array and then tell the table view to reload data. For example:

Swift:
Code: [Select]
myArray.removeAll()
tableView.reloadData()

Objective-C:

Code: [Select]
[myArray removeAllObjects];
[tableView reloadData];

All the best!
Kevin McNeish
Author of "Learn to Code in Swift": https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
« Last Edit: July 22, 2015, 05:32:29 AM by kjmcneish »