title: How To Pass ManagedObjectContext To Other View Controllers in Special Case
body: <p>I have a rootViewController like so:</p>
  
  <p>Header:</p>
  
  <pre><code>@interface ParkingRootViewController : UIViewController {
      UINavigationController *navigationController;
      UIToolbar *toolbar;
      UIBarButtonItem *lastUpdateLabel;
  
      NSPersistentStoreCoordinator *persistentStoreCoordinator;
      NSManagedObjectModel *managedObjectModel;
      NSManagedObjectContext *managedObjectContext;
  }
  
  @property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
  @property (nonatomic, retain) IBOutlet UIToolbar *toolbar;
  @property (nonatomic, retain) IBOutlet UIBarButtonItem *lastUpdateLabel;
  
  @property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel;
  @property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext;
  @property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
  
  @property (nonatomic, readonly) NSString *applicationDocumentsDirectory;
  
  -(IBAction)selectHome:(id)sender;
  //-(void)loadOverlays;
  -(void)testCoreData;
  
  @end
  </code></pre>
  
  <p>Implementation:</p>
  
  <pre><code>// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  - (void)viewDidLoad {
      [super viewDidLoad];
  
      //...
  
      [self testCoreData];
  
      //creating label in tool bar 
      UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 150.0f, 20.0f)];
      label.text = @"last updated...";
      label.textColor = [UIColor colorWithWhite:1.0 alpha:1.0];
      label.backgroundColor = [UIColor clearColor];
      label.textAlignment = UITextAlignmentCenter;
      //label.highlightedTextColor = [UIColor colorWithWhite:0.5 alpha:1.0];
      //label.highlighted = YES;
      label.font = [UIFont systemFontOfSize:13.0];
      label.userInteractionEnabled = NO;
  
      [lastUpdateLabel initWithCustomView:label];
      [label release];
  
      [self.view addSubview:self.navigationController.view];
  
      [self.navigationController.view setFrame:self.view.frame];
  
  }
  </code></pre>
  
  <p>But I need to transfer my managedObjectModel to my table view and then to a map view so that the map view can make queries depending on what the user wants to see. I was consulting some apple sample code which looks like(from Recipes):</p>
  
  <pre><code>- (void)applicationDidFinishLaunching:(UIApplication *)application {
      recipeListController.managedObjectContext = self.managedObjectContext;
      [window addSubview:tabBarController.view];
      [window makeKeyAndVisible];
  }
  </code></pre>
  
  <p>I know that is in the appDelegate, but I figure that I can do the same when a row is selected or another view is pushed onto the stack, right? The problem is that I have configured most of my view with a nib which looks like so:</p>
  
  <p><img src="https://i.stack.imgur.com/C4njk.png" alt="alt text"></p>
  
  <p>Due to this, I am unable to use a similar strategy that Apple employs to transfer a managedObjectModel to an alternate viewController(in this case PermitListViewController) because I don't access PermitListViewController directly when adding a subview. If anyone has any idea of how I would go about getting my managedObjectModel to my PermitListViewController. Please share! Thanks in advance!</p>
  
  <p>EDIT: I am thinking of placing the managedObjectModel in a singleton class. What are your guys' thoughts on that? Good programming practice? Anything I should be aware of? Thanks.</p>