views:

643

answers:

1

I have a navigation view with a cell that has something as simple as a Date of Birth. When that particular row is clicked, a new controller get pushed into view with a UIDatePicker. Once a new date is selected, I'd imagine I need to do something in viewWillDisappear: for that particular cell's UITextField value. What's the best way for me to do that? Do I need to pass in a reference to the cell's indexPath in the childController, set it there, and reload the tableView's data?

Another tricky tidbit is let's say that my data source for the tableView is a dictionary with key/value pairs. When I call reloadData on the tableView, it'll re-read that dictionary without taking into note the date change my child controller has made.

+2  A: 

First, the best place to reload data is in that particular UIViewController's viewWillAppear: method. That way you don't need to worry about references to the table in other controllers.

Second, if I'm not misunderstanding, I think you need to brush up on objects. As long as what you change in the editing (child) controller is a reference to the same object that the table (parent) controller uses, the data will be synced. If, on the other hand, you're reloading data (say, from a file) for each controller, I'd take a look at how your app architecture works. Objects are your friend. Take advantage of that.

August