Trigger table refresh on data change

Discussion in 'iOS Programming' started by BNZ1, Apr 6, 2009.

  1. macrumors regular

    Joined:
    Nov 11, 2008
    Location:
    London
    #1
    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.
     
  2. macrumors member

    Joined:
    Jul 28, 2008
    #2
    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.
     
  3. thread starter macrumors regular

    Joined:
    Nov 11, 2008
    Location:
    London
    #3
    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?
     
  4. thread starter macrumors regular

    Joined:
    Nov 11, 2008
    Location:
    London

Share This Page