How do I update the row count in a TableView in Swift?
Suppose I initially configured my row count as such:
func tableView(tableView:UITableView!, numberOfRowsInSection section: Int) -> Int {
return 100
}
If I add something to the table and call
self.tableView.reloadData()
How do I get the number of rows to update to 101? Can I somehow call this function again but return 101?
+3
source to share
1 answer
I suggest you learn MVC design pattern first, it is helpful when you are learning ios coding. Then when you are using a dynamic table view, I think you should keep the tableveiw datasource.
For example In your tableview controller
save Array as data source:
var Array = [something you want]
Then in
func tableView(tableView:UITableView!, numberOfRowsInSection section: Int) -> Int {
return array.count
}
Then if you want to change the interface, just change that array and reload or insert / remove lines
+8
user4201217
source
to share