views:

188

answers:

1

Hi there, Say I have two UIViewControllers, all working under a UINavigationController:

  1. RootViewController hosts a UITableView which contains a list of domain names.
  2. CodeViewController shows a domain.

A user can view any domain they like; once the domain is viewed in CodeViewController, the name is added to the store via Core Data.

When the user hits the back button to return to the RootViewController, I want that new domain to appear in the UITableView. I can't make this happen.

I've attempted several techniques like flushing out the array that supplies the values to the table; I've put my CD calls into viewWillAppear (currently in viewDidLoad).

On the Mac, I'd just use bindings to bind the table to the CD model, but how would you do it on the iPhone? I'm stumped!

Thanks, Aaron.

+3  A: 

Typically you implement an NSFetchedResultsController in between your Core Data data and your table view.

It has delegate methods such controllerDidChangeContent: to inform you that the content has changed and the table view needs updating (you could call reloadData on the table view).

gerry3
I'd never heard of NSFetchedResultsController, and with some fussing around, I got it to work! Thanks so much for your help! I found these two Apple docs helped: http://developer.apple.com/iphone/library/documentation/CoreData/Reference/NSFetchedResultsController_Class/Reference/Reference.html and http://developer.apple.com/iphone/library/documentation/CoreData/Reference/NSFetchedResultsControllerDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSFetchedResultsControllerDelegate
Aaron Vegh