Add computed property to FileProviderConfig to get and set internal config

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-02-05 18:15:45 +08:00
parent 1fc6014230
commit f987bcd97a

View file

@ -15,4 +15,19 @@ struct FileProviderConfig {
let domainIdentifier: NSFileProviderDomainIdentifier
private var internalConfig: [String: Any] {
get {
let defaults = UserDefaults.standard
if let settings = defaults.dictionary(forKey: domainIdentifier.rawValue) {
return settings
}
let dictionary: [String: Any] = [:]
defaults.setValue(dictionary, forKey: domainIdentifier.rawValue)
return dictionary
}
set {
let defaults = UserDefaults.standard
defaults.setValue(newValue, forKey: domainIdentifier.rawValue)
}
}
}