mastodon-app-ufficiale-ipho.../MastodonSDK/Sources/CoreDataStack/Extension/URL.swift

24 lines
687 B
Swift
Raw Normal View History

2021-01-27 07:50:13 +01:00
//
// URL.swift
// CoreDataStack
//
// Created by Cirno MainasuK on 2021-1-27.
//
import Foundation
public extension URL {
/// Returns a URL for the given app group and database pointing to the sqlite database.
static func storeURL(for appGroup: String, databaseName: String) -> URL {
guard let fileContainer = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroup) else {
fatalError("Shared file container could not be created.")
}
return fileContainer
.appendingPathComponent("Databases", isDirectory: true)
.appendingPathComponent("\(databaseName).sqlite")
}
}