 
             self.managedObjectContext.persistentStoreCoordinator = coordinator
 
-            if !FileManager.default.fileExists(atPath: directoryURL.absoluteString) {
-                do {
-                    try FileManager.default.createDirectory(at: directoryURL, withIntermediateDirectories: true, attributes: [FileAttributeKey.protectionKey: FileProtectionType.none])
-                } catch {
-                    // Ignore errors here, let Core Data explain the problem
-                }
+            do {
+                try FileManager.default.ensureDirectoryExists(at: directoryURL, with: FileProtectionType.completeUntilFirstUserAuthentication)
+            } catch {
+                // Ignore errors here, let Core Data explain the problem
             }
 
             let storeURL = directoryURL.appendingPathComponent("Model.sqlite")

        }
    }
}

                    options: [
                        NSMigratePersistentStoresAutomaticallyOption: true,
                        NSInferMappingModelAutomaticallyOption: true,
                        NSPersistentStoreFileProtectionKey: FileProtectionType.completeUntilFirstUserAuthentication
                    ]
                )
            } catch let storeError as NSError {
