PDA

View Full Version : Trigger table refresh on data change




BNZ1
Apr 6, 2009, 12:41 PM
Hi Guys,

I have a tableView (inside a tab view) that pulls its data from an NSObject datacontroller file. The data contained in this is a list of locations, including the distance from the current location.

I am struggling to find the best way to automatically reload the table data on the event of a data update which is triggered whenever the phone recieves a location update.

Is there a standard way for my datacontroller file to trigger a table reload whenever its data is updated, or would I be better using a time based reload in the tableView (I prefer the concept of data triggered update, with the adjustment coming from setting a distance moved variable).

Thanks.



Taum
Apr 6, 2009, 02:14 PM
Hi,

You can use reloadData to reload the whole table, or more fine-grained methods like those found under "Inserting and Deleting Cells" and "Reloading the Table View" in the docs for UITableView.

BNZ1
Apr 6, 2009, 02:17 PM
Hi,

You can use reloadData to reload the whole table, or more fine-grained methods like those found under "Inserting and Deleting Cells" and "Reloading the Table View" in the docs for UITableView.

Thanks,

It is not the reloading of the data itself causing me the issue, it is the trigger to reload the data. I think I may need a protocol/delegate/notification from my Datasource that triggers every time it updates itself? Does this sound right?

I cant directly tell a tableView to reload from my datasource, so I need to tell the tableViewController that the data has changed, and then the tableViewController needs to know to trigger a reloadData with this information?

BNZ1
Apr 6, 2009, 05:38 PM
Bridge passed - NSNotificationCenter :D