I need to to fetch realtime news from API, and then show them in a UITableView
, news must disappear 5 seconds after their arrival.
I am new in Swift, I know that UITableView has reloadData()
that is meant to update the data in the table, I suppose I should use this method.
My idea is to call the API every 5 seconds, but how it works update/animation for making disappearing the news and adding new ones in the table?
When you get the data from api, update your Data_Source(i.e. the list or array from which you are populating the UITableView
) and after that call reloadData()
. So UITableView
will reload every time the data comes from api.
If you want to show only the new data then assign
=
the new data to your array, or want to add/append then append
new data in old array.