0

I have an tabbed application that captures data, stores it using NSUserDefaults and presents a readout in a table that is contained in a UIViewController. I am using a navigation controller between the tab view controller and the data view. The data view is then connected to a history view controller which is a child view controller. The history also has a table.

When you press a row in the history view, the app is supposed to transition back to the data view and present the readout for the history. This is done by making the data the first NSUserDefault which is then presented in the data view. THe transition I am using is

[self.navigationController popToRootViewControllerAnimated:YES];

This transitions back to the data view successfully however it does not change the data in the view. However,when I remove that code and press the row and then press back, the readout is changed. How do I make the readout change on press of the row?

Aaron
  • 7,055
  • 2
  • 38
  • 53
Chip Cary
  • 65
  • 1
  • 1
  • 10
  • You need to give a better description of your controller structure, what you've written in that first paragraph is confusing. Also, using NSUserDefaults as a way to transfer data between controllers is not what they're designed for. You probably should be using delegation. – rdelmar May 20 '13 at 20:35
  • Update- I just noticed that when loading dataView from historyView, the data does change but only after scrolling down the table and scrolling back up – Chip Cary May 20 '13 at 20:53

3 Answers3

0

Try to use delegates/protocol,

Set your dataview as delegate to the protocol in history view. Before calling pop, call the delegate action. Then in the action, just refresh ur view in dataview and then call poptoroot.

Just google protocol/delegate example, there should be many.

Pavan Kris
  • 29
  • 1
  • 4
0

Delegates / Protocols. The answers are abundant here for passing data between view controllers.

passing-data-between-view-controllers

Community
  • 1
  • 1
Mark McCorkle
  • 9,349
  • 2
  • 32
  • 42
0

All that I ended up having to do was implement

[self.dataTable reloadData]
Chip Cary
  • 65
  • 1
  • 1
  • 10