 }
 
 extension NSBundle {
-
+    
     private func defaultManagedObjectModelURL() -> NSURL? {
         if let managedObjectModelName = self.bundleName {
             return self.managedObjectModelURLForManagedObjectModelName(managedObjectModelName)

        self.options[NSPersistentStoreUbiquitousContainerIdentifierKey] = ubiquitousContainerIdentifier
        self.options[NSPersistentStoreUbiquitousContentURLKey] = ubiquitousContentURL
        self.options[NSPersistentStoreUbiquitousContentNameKey] = ubiquitousContentName

        self.options[NSMigratePersistentStoresAutomaticallyOption] = true
        self.options[NSInferMappingModelAutomaticallyOption] = true
    }

        
        return nil
    }
    
}

extension NSBundle {
    
    private func managedObjectModelURLForManagedObjectModelName(managedObjectModelName: String) -> NSURL? {
        return self.URLForResource(managedObjectModelName, withExtension: "momd")
    }
    
    private func persistentStoreURLForManagedObjectModelName(managedObjectModelName: String, bundleIdentifier: String) -> NSURL? {
        if let applicationSupportURL = NSFileManager.defaultManager().URLsForDirectory(.ApplicationSupportDirectory, inDomains: .UserDomainMask).last as? NSURL {
            let url = applicationSupportURL
                .URLByAppendingPathComponent(bundleIdentifier, isDirectory: true)
                .URLByAppendingPathComponent("CoreData", isDirectory: true)
                .URLByAppendingPathComponent(managedObjectModelName.stringByAppendingPathExtension("sqlite")!, isDirectory: false)
            
            return url
        }
        
        return nil
    }
    
    private func persistentStoreURLForManagedObjectModelName(managedObjectModelName: String, bundleIdentifier: String, applicationGroupIdentifier: String) -> NSURL? {
        if let containerURL = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier(applicationGroupIdentifier) {
            let url = containerURL
                .URLByAppendingPathComponent("Library", isDirectory: true)
                .URLByAppendingPathComponent("Application Support", isDirectory: true)
                .URLByAppendingPathComponent(bundleIdentifier, isDirectory: true)
                .URLByAppendingPathComponent("CoreData", isDirectory: true)
                .URLByAppendingPathComponent(managedObjectModelName.stringByAppendingPathExtension("sqlite")!, isDirectory: false)
            
            return url
        }
        
        return nil
