How to share a UIManagedDocument using Storyboards with a Tab Bar Controller as initial controller?

Up vote 2 down vote favorite share g+ share fb share tw.

My application uses locations data and presents it both as a table and in a map. It starts with a Tab Bar Controller, each of it's views is a Navigation Controller (one for the table view, one for the map, etc...). I want to share a UIManagedObject in order to use the same Managed Object Context so if the user updates at the table view, the data also gets updated for the map, so there is no need to update twice.

Originally I thought of subclassing the Tab Bar Controller and adding a UIManagedDocument as a property, and just passing it to each controller on the prepare for segue method. But I read that UITabBarController is not meant to be subclassed. Another approach could be creating a View Controller, adding the Managed Document as property, and a Tab Bar to it.

But I think that my storyboard would be unclear or inconsistent by showing some relationships graphically and others just in code. Which one is the appropriate? Or is there a better way to do it?

Thanks in advance and best regards. Ios core-data ios5 uitabbarcontroller uistoryboard link|improve this question edited Mar 7 at 21:47 asked Feb 24 at 9:12Armando184.

(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if (segue identifier isEqualToString:@"showGuide") { UITabBarController *tabBarController = (UITabBarController *)segue destinationViewController; for (id vc in tabBarController. ViewControllers) { vc setValue:_document forKey:@"document"; } }.

– Armando Mar 22 at 20:34 No, this is should be written in ViewController, that stands before TabBarController. What I used here called Key Value Coding design pattern. Using it I assigned "document" property of each TabBarController's controller to self.document.

– Flink Mar 23 at 9:30 Good tutorial to use UIManagedDocument: informit.com/articles/article.aspx?p=184... – Flink Mar 23 at 9:31.

I ran into this issue too and I settled on a separate document handler class that provides access to the loaded document via a block. MYDocumentHandler sharedDocumentHandler performWithDocument:^(UIManagedDocument *document) { // Do stuff with the document, set up a fetched results controller, whatever. }; I've written up my solution and posted the code here: Core Data with a Single Shared UIManagedDocument.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions