views:

62

answers:

1

The documentation for the NSFetchedResultsController states that it is intended for use to 'efficiently manage the results returned from a Core Data fetch request to provide data for a UITableView object'.

Could I use an NSFetchedResultsController to manage a collection of map annotations as well? I am not sure how I would do this. Any ideas?

+3  A: 

I assume that you mean that you want something to manage a collection of Core Data objects that will be used to create annotations.

You should use a standard collection: NSArray or NSSet (or NSMutableArray or NSMutableSet).

Check out the NSManagedObjectContext method executeFetchRequest:error:.

gerry3
Yes, that is probably what I want to do. Thanks.Now I need to find a way to keep the local array in sync with the edits happening in the table view. I'm thinking doing that through notifications. Is that what you would do?
mvexel
I would use notifications if I had editable controls displayed at the same time as the view that needs to be updated. However, these views are often displayed at different times. In that case, the view controller that handles the view with the controls will update the model after its view has been dismissed. Then, other views can be updated based on the model in their controller's viewWillAppear method.
gerry3
viewWillAppear, that seems a good place to handle this. Thanks. The view to be updated is invisible while the managed object context is volatile.
mvexel
Yes, it should work then.
gerry3