struct CapturaSettings {
static var frameRate: Int {
get {
- UserDefaults.standard.integer(forKey: "frameRate")
+ if NSUbiquitousKeyValueStore.default.object(forKey: "frameRate") == nil {
+ return 10
+ } else {
+ return min(10, max(4, Int(NSUbiquitousKeyValueStore.default.longLong(forKey: "frameRate"))))
+ }
}
set {
- UserDefaults.standard.setValue(newValue, forKey: "frameRate")
+ NSUbiquitousKeyValueStore.default.setValue(newValue, forKey: "frameRate")
}
}
static var outputFormats: OutputFormatSetting {
get {
- OutputFormatSetting(rawValue: UserDefaults.standard.integer(forKey: "outputFormats")) ?? .all
+ OutputFormatSetting(rawValue: Int(NSUbiquitousKeyValueStore.default.longLong(forKey: "outputFormats"))) ?? .all
}
set {
- UserDefaults.standard.setValue(newValue.rawValue, forKey: "outputFormats")
+ NSUbiquitousKeyValueStore.default.setValue(newValue.rawValue, forKey: "outputFormats")
}
}
static var backend: URL? {
get {
- if let url = UserDefaults.standard.string(forKey: "backendUrl") {
+ if let url = NSUbiquitousKeyValueStore.default.string(forKey: "backendUrl") {
return URL(string: url)
}
return nil
}
set {
- UserDefaults.standard.setValue(newValue?.absoluteString, forKey: "backendUrl")
+ NSUbiquitousKeyValueStore.default.setValue(newValue?.absoluteString, forKey: "backendUrl")
}
}
static var backendFormat: OutputFormatSetting {
get {
- OutputFormatSetting(rawValue: UserDefaults.standard.integer(forKey: "backendFormat")) ?? .gifOnly
+ OutputFormatSetting(rawValue: Int(NSUbiquitousKeyValueStore.default.longLong(forKey: "backendFormat"))) ?? .gifOnly
}
set {
- UserDefaults.standard.setValue(newValue.rawValue, forKey: "backendFormat")
+ NSUbiquitousKeyValueStore.default.setValue(newValue.rawValue, forKey: "backendFormat")
}
}
static var shouldKeepLocalFiles: Bool {
get {
- UserDefaults.standard.bool(forKey: "keepFiles")
+ if NSUbiquitousKeyValueStore.default.object(forKey: "keepFiles") == nil {
+ return true
+ } else {
+ return NSUbiquitousKeyValueStore.default.bool(forKey: "keepFiles")
+ }
}
set {
- UserDefaults.standard.set(newValue, forKey: "keepFiles")
+ NSUbiquitousKeyValueStore.default.set(newValue, forKey: "keepFiles")
}
}
static var shouldAllowURLAutomation: Bool {
- UserDefaults.standard.bool(forKey: "allowURLAutomation")
+ get {
+ NSUbiquitousKeyValueStore.default.bool(forKey: "allowURLAutomation")
+ }
+ set {
+ NSUbiquitousKeyValueStore.default.setValue(newValue, forKey: "allowURLAutomation")
+ }
}
static func apply(_ config: ConfigureAction) {