title: Realm sharing database through Groups with app extension
body: <p>I have an app with a today extension. In appDelegate.swift for the main app:</p>
  
  <pre><code>func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -&gt; Bool {
      let directory: NSURL = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier("group.Hobo.RealmDatabase")!
      var config = Realm.Configuration()
      config.fileURL = directory.filePathURL?.URLByAppendingPathComponent("db.realm")
      Realm.Configuration.defaultConfiguration = config
      return true
  }
  </code></pre>
  
  <p>In my todayExtension's viewDidload:</p>
  
  <pre><code> override func viewDidLoad() {
      super.viewDidLoad()
      let directory: NSURL = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier("group.Hobo.RealmDatabase")!
      var config = Realm.Configuration()
      config.fileURL = directory.filePathURL?.URLByAppendingPathComponent("db.realm")
      Realm.Configuration.defaultConfiguration = config
  
      let realm = try! Realm()
  }
  </code></pre>
  
  <p>When I create an object in my main app, it persists in the database. However when I try to read the number of objects from todayExtensionViewController, it returns 0, meaning no objects were created.</p>
  
  <p>I am confused because since both the apps getting the same Realm data from the same location, isn't it supposed to "share" the data? </p>
  
  <p>I'm using groups to share data between apps.</p>
  
  <p>Thanks in advance!</p>