CachingManager.swift
1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// FirstTimeOpen.swift
// browser
//
// Created by Artem Talko on 27.09.2023.
//
import Foundation
final class CachingManager {
private enum Keys {
static let isFirstAppLoad = "IsFirstAppLoad"
static let isAdBlocking = "IsAdBlocking"
static let expirationDate = "ExpirationDate"
}
static let shared = CachingManager()
private let userDefaults = UserDefaults.standard
private init() {}
var isFirstAppLoad: Bool {
get { return userDefaults.bool(forKey: Keys.isFirstAppLoad) }
set { userDefaults.set(newValue, forKey: Keys.isFirstAppLoad) }
}
var adBlockerState: Bool {
get { return userDefaults.bool(forKey: Keys.isAdBlocking) }
set { userDefaults.set(newValue, forKey: Keys.isAdBlocking) }
}
var expirationDate: Double? {
get {
if userDefaults.object(forKey: Keys.expirationDate) == nil {
return nil
}
return userDefaults.double(forKey: Keys.expirationDate)
}
set { userDefaults.set(newValue, forKey: Keys.expirationDate) }
}
}