Refresh data in UITableView

I have a UITableView and I charged it with data in viewDidAppear. and it succeeds.

The problem is that I have to update UITableView data frequently (every 300 seconds). So I defined a timer and charged the UITableView dataSource when the timer throws an event of the end of the time interval (300 seconds). BUT nothing changes !!! Data is still being saved.

Any help would be appreciated.

Sorry for my English.

+4
source share
2 answers

Try [tableView reloadData]

+6
source

You do not populate the data actively, you simply implement the data source delegates.

If the data has been changed, use [yourTableView reloadData] to update, the table will retrieve the data it needs. There are methods for reloading partitions or multiple lines if you know what has changed and want to animate it.

Also, be sure to call the main thread (if your timer fires in another thread).

+2
source

Source: https://habr.com/ru/post/1313656/


All Articles