diana
diana

Reputation: 427

Adding and updating table view simultaneously

I have an array whose contents are updated and new entries are added on every seconds. How can i show the contents of an array in a table view so that i can see the newly inserted rows and updation of the added row.Can anyone help me.

Thanks in advance!!!

Upvotes: 0

Views: 123

Answers (2)

Jake
Jake

Reputation: 3973

The answer suggested; [theTableView reload] definitely works fine. If you update the table every view seconds, however, your users will hate you.

Try to capture the reloading data in a notification handler. In that handler, check if the updated data belongs somewhere between the currently visible cells, if so, update the currently visible view. If not, ignore the updated data (but do add it to your underlying model). If the user scrolls further, after your update, cellForIndexPath: is called and the updated data will be drawn automatically.

reload is quite heavy to do every view seconds, certainly with a lot of data. drawing might get screwed up or worse..

Upvotes: 2

ennuikiller
ennuikiller

Reputation: 46965

You need to do a reload every time your datasource is updated. So if you table view is theTableView you would execute this instruction after your array is updated:

[theTableView reload]

Upvotes: 0

Related Questions