How do you save CoreData with UIPickerView and then load CoreData with UITableView?
I have a multiview application using a tab bar to switch views. One is a pickerview while the other two are a table view and a 开发者_如何学Pythonview with 4 text fields (and one other table view that just contains instructions on how to use the app). I want to use core data to save selected rows in the picker view and also save strings that are entered in the text field view. The table view will obviously display all these saved results. So how do I link all these together? Do I create an abstract class just for the core data methods (including the fetchedResultsController) so each view controller can subclass and access the managedobjects and methods from said abstract class? Or is there a better way to do this?
What I would do is implement a <UITabBarDelegate> class to act as the hub for data for the tabs, since they're all operating on the same data set. When a tab is selected, hand it the NSManagedObjects it needs for display (in the case of the history tab, that will be your main array of objects...). You'll minimize repetition and the need to hand around the key Core Data objects (NSManagedObjectContext, etc).
精彩评论