Child controller updating label for cell in parent table view

I have a navigation view with a cell that has something as simple as a date of birth. When this particular line is pressed, the new controller comes into view using UIDatePicker. As soon as a new date has been selected, I would guess that I need to do something in viewWillDisappear: for this value UITextField cell. What is the best way for me to do this? Do I need to pass a reference to a cell in indexPath childController, install it there and reload the data tableView?

Another difficult lure can say that my data source for tableView - a dictionary with the key / value pairs. When I call reloadData in the tableView, he reads the dictionary, without taking into account the change of the date, which made my child controller.

+3
source share
1 answer

First, the best place to reload the data is that this method UIViewControllerWillAppear :. Thus, you do not need to worry about on the table references to other controllers.

Second, if I'm not misunderstood, I think you need to refresh objects. As long as you change the controller (child), a reference to the same object, which is used by the controller of the table (the parent), the data will be synchronized. If, on the other hand, you reset the data (say, a file) for each controller, I would look, how your application architecture. Objects - your friend. Take advantage of this.

+4
source

All Articles