views:

83

answers:

2

ViewA load some data from Coredata, then push to the next viewB. In viewB, there are some function, that will change the content of viewA (meaning viewB change the content of core data). However, when I pop the view back to viewA, my content stay the same as before. How can I fix this?

+3  A: 

in viewA's -(void)viewWillAppear:(BOOL)animated delegate method you can refresh the control you need... i.e. if you want to reload table that in viewWillAppear method write

[Table reloadData];
mihirpmehta
This is not always necessary that a person is using a table view to show data.....
Madhup
very true ...but i have given just one example... and TableView is most widely used Control so i have chosen it...so that's why you have down voted my answer... funny...
mihirpmehta
A: 

There are two ways to do this:

The content of viewA that u would be setting in viewDidLoad method of the viewCOntroller of viewA can be set in viewWillAppear. In this way the contents of the view will be reloaded always when a view is appeared.

The other way is little tough but much more efficient in terms of performance. Have a boolean variable in viewA, now its value should be set to true when u change any thing in viewB by having its reference in viewB, now when you pop check in viewWillAppear if the boolean is changed to true. if yes set it to no again and call the method that you called from view did load to load the data in the viewA.

Hope this helps.

Thanks,

Madhup

Madhup