title: How to access CoreData model in today extension (iOS)
body: <p>Is it possible to work with my CoreData model in the today extension in swift like in the original app? If yes, how can I create the NSManagedObjectContext? <br>
  I really have no clue, beside the group-identifier, but unfortunatly I don't know how to get the context.. <br>
  In the past I created apps with the check at the beginning that I want to use CoreData and then I got the managedObjectContext via my AppDelegate.. But how can I do somethink like that in an extension? Apple doesn't offer information about that..</p>
  
  <p>I edited this line in AppDelegate:</p>
  
  <pre><code>NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"HTWcampus.sqlite"];
  </code></pre>
  
  <p>to this (after including the group to both targets):</p>
  
  <pre><code>NSURL *storeURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:@"group.BenchR.TodayExtensionSharingDefaults"];
  storeURL = [storeURL URLByAppendingPathComponent:@"HTWcampus.sqlite"];
  NSLog(@"StoreURL2: %@", storeURL);
  </code></pre>
  
  <p>With that the existing database in my app was gone (what is great, because I think it worked to put the database in the shared segment).</p>
  
  <p>But how can I create an instance of my context in the extension? And how can I access my NSManagedObject-subclasses?</p>
  
  <p>In the extension I have this code so far:</p>
  
  <pre><code>var context: NSManagedObjectContext!
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      var storeURL = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier("group.BenchR.TodayExtensionSharingDefaults")
      storeURL = storeURL?.URLByAppendingPathComponent("HTWcampus.sqlite")
      let modelURL = NSBundle.mainBundle().URLForResource("HTWcampus", withExtension: "momd")
      let model = NSManagedObjectModel(contentsOfURL: modelURL)
      let coordinator = NSPersistentStoreCoordinator(managedObjectModel: model)
      coordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: storeURL, options: nil, error: nil)
      context = NSManagedObjectContext()
      context.persistentStoreCoordinator = coordinator
  }
  </code></pre>
  
  <p>Is this right? And if yes, how can I get my NSManagedObject-Subclasses in there? And do I have to add the momd-file to the extensions target? If yes, how can I do that?</p>