@@ -102,182 +102,128 @@ public class UserDefaultsManager: NSObject {
102
102
103
103
/// The last ETag received from the server.
104
104
@objc public var lastETag : String ? {
105
- return instanceUserDefaults [ kRCNUserDefaultsKeyNamelastETag] as? String
106
- }
107
-
108
- /// Sets the last ETag received from the server.
109
- ///
110
- /// - Parameter lastETag: The last ETag received from the server.
111
- @objc public func setLastETag( _ lastETag: String ? ) {
112
- if let lastETag = lastETag {
113
- setInstanceUserDefaultsValue ( lastETag, forKey: kRCNUserDefaultsKeyNamelastETag)
105
+ get { instanceUserDefaults [ kRCNUserDefaultsKeyNamelastETag] as? String }
106
+ set {
107
+ if let lastETag = newValue {
108
+ setInstanceUserDefaultsValue ( lastETag, forKey: kRCNUserDefaultsKeyNamelastETag)
109
+ }
114
110
}
115
111
}
116
112
117
113
/// The last fetched template version.
118
114
@objc public var lastFetchedTemplateVersion : String {
119
- return instanceUserDefaults [ ConfigConstants . fetchResponseKeyTemplateVersion] as? String ?? " 0 "
120
- }
121
-
122
- /// Sets the last fetched template version.
123
- ///
124
- /// - Parameter templateVersion: The last fetched template version.
125
- @objc public func setLastFetchedTemplateVersion( _ templateVersion: String ) {
126
- setInstanceUserDefaultsValue (
127
- templateVersion,
128
- forKey: ConfigConstants . fetchResponseKeyTemplateVersion
129
- )
115
+ get { instanceUserDefaults [ ConfigConstants . fetchResponseKeyTemplateVersion] as? String ?? " 0 " }
116
+ set {
117
+ setInstanceUserDefaultsValue (
118
+ newValue,
119
+ forKey: ConfigConstants . fetchResponseKeyTemplateVersion
120
+ )
121
+ }
130
122
}
131
123
132
124
/// The last active template version.
133
125
@objc public var lastActiveTemplateVersion : String {
134
- return instanceUserDefaults [ ConfigConstants . activeKeyTemplateVersion] as? String ?? " 0 "
135
- }
136
-
137
- /// Sets the last active template version.
138
- ///
139
- /// - Parameter templateVersion: The last active template version.
140
- @objc public func setLastActiveTemplateVersion( _ templateVersion: String ) {
141
- setInstanceUserDefaultsValue ( templateVersion, forKey: ConfigConstants . activeKeyTemplateVersion)
126
+ get { instanceUserDefaults [ ConfigConstants . activeKeyTemplateVersion] as? String ?? " 0 " }
127
+ set {
128
+ setInstanceUserDefaultsValue ( newValue, forKey: ConfigConstants . activeKeyTemplateVersion)
129
+ }
142
130
}
143
131
144
132
/// The last ETag update time.
145
133
@objc public var lastETagUpdateTime : TimeInterval {
146
- return instanceUserDefaults [ kRCNUserDefaultsKeyNamelastETagUpdateTime] as? TimeInterval ?? 0
147
- }
148
-
149
- /// Sets the last ETag update time.
150
- ///
151
- /// - Parameter lastETagUpdateTime: The last ETag update time.
152
- @objc public func setLastETagUpdateTime( _ lastETagUpdateTime: TimeInterval ) {
153
- setInstanceUserDefaultsValue (
154
- lastETagUpdateTime,
155
- forKey: kRCNUserDefaultsKeyNamelastETagUpdateTime
156
- )
134
+ get { instanceUserDefaults [ kRCNUserDefaultsKeyNamelastETagUpdateTime] as? TimeInterval ?? 0 }
135
+ set {
136
+ setInstanceUserDefaultsValue ( newValue, forKey: kRCNUserDefaultsKeyNamelastETagUpdateTime)
137
+ }
157
138
}
158
139
159
140
/// The last fetch time.
160
141
@objc public var lastFetchTime : TimeInterval {
161
- return instanceUserDefaults [ kRCNUserDefaultsKeyNameLastSuccessfulFetchTime] as? TimeInterval ??
162
- 0
163
- }
164
-
165
- /// Sets the last fetch time.
166
- ///
167
- /// - Parameter lastFetchTime: The last fetch time.
168
- @objc public func setLastFetchTime( _ lastFetchTime: TimeInterval ) {
169
- setInstanceUserDefaultsValue (
170
- lastFetchTime,
171
- forKey: kRCNUserDefaultsKeyNameLastSuccessfulFetchTime
172
- )
142
+ get {
143
+ instanceUserDefaults [ kRCNUserDefaultsKeyNameLastSuccessfulFetchTime] as? TimeInterval ?? 0
144
+ }
145
+ set {
146
+ setInstanceUserDefaultsValue ( newValue, forKey: kRCNUserDefaultsKeyNameLastSuccessfulFetchTime)
147
+ }
173
148
}
174
149
175
150
/// The last fetch status.
176
151
@objc public var lastFetchStatus : String ? {
177
- return instanceUserDefaults [ kRCNUserDefaultsKeyNamelastFetchStatus] as? String
178
- }
179
-
180
- /// Sets the last fetch status.
181
- ///
182
- /// - Parameter lastFetchStatus: The last fetch status.
183
- @objc public func setLastFetchStatus( _ lastFetchStatus: String ? ) {
184
- if let lastFetchStatus = lastFetchStatus {
185
- setInstanceUserDefaultsValue ( lastFetchStatus, forKey: kRCNUserDefaultsKeyNamelastFetchStatus)
152
+ get { instanceUserDefaults [ kRCNUserDefaultsKeyNamelastFetchStatus] as? String }
153
+ set {
154
+ if let lastFetchStatus = newValue {
155
+ setInstanceUserDefaultsValue (
156
+ lastFetchStatus,
157
+ forKey: kRCNUserDefaultsKeyNamelastFetchStatus
158
+ )
159
+ }
186
160
}
187
161
}
188
162
189
163
/// Whether the client is throttled with exponential backoff.
190
164
@objc public var isClientThrottledWithExponentialBackoff : Bool {
191
- return instanceUserDefaults [ kRCNUserDefaultsKeyNameIsClientThrottled] as? Bool ?? false
192
- }
193
-
194
- /// Sets whether the client is throttled with exponential backoff.
195
- ///
196
- /// - Parameter isThrottledWithExponentialBackoff: Whether the client is throttled with
197
- /// exponential backoff.
198
- @objc public func setIsClientThrottledWithExponentialBackoff( _ isThrottledWithExponentialBackoff: Bool ) {
199
- setInstanceUserDefaultsValue (
200
- isThrottledWithExponentialBackoff,
201
- forKey: kRCNUserDefaultsKeyNameIsClientThrottled
202
- )
165
+ get { instanceUserDefaults [ kRCNUserDefaultsKeyNameIsClientThrottled] as? Bool ?? false }
166
+ set {
167
+ setInstanceUserDefaultsValue (
168
+ newValue,
169
+ forKey: kRCNUserDefaultsKeyNameIsClientThrottled
170
+ )
171
+ }
203
172
}
204
173
205
174
/// The throttle end time.
206
175
@objc public var throttleEndTime : TimeInterval {
207
- return instanceUserDefaults [ kRCNUserDefaultsKeyNameThrottleEndTime] as? TimeInterval ?? 0
208
- }
209
-
210
- /// Sets the throttle end time.
211
- ///
212
- /// - Parameter throttleEndTime: The throttle end time.
213
- @objc public func setThrottleEndTime( _ throttleEndTime: TimeInterval ) {
214
- setInstanceUserDefaultsValue ( throttleEndTime, forKey: kRCNUserDefaultsKeyNameThrottleEndTime)
176
+ get { instanceUserDefaults [ kRCNUserDefaultsKeyNameThrottleEndTime] as? TimeInterval ?? 0 }
177
+ set {
178
+ setInstanceUserDefaultsValue ( newValue, forKey: kRCNUserDefaultsKeyNameThrottleEndTime)
179
+ }
215
180
}
216
181
217
182
/// The current throttling retry interval in seconds.
218
183
@objc public var currentThrottlingRetryIntervalSeconds : TimeInterval {
219
- return instanceUserDefaults [
220
- kRCNUserDefaultsKeyNameCurrentThrottlingRetryInterval
221
- ] as? TimeInterval ??
222
- 0
223
- }
224
-
225
- /// Sets the current throttling retry interval in seconds.
226
- ///
227
- /// - Parameter throttlingRetryIntervalSeconds: The current throttling retry interval in seconds.
228
- @objc public func setCurrentThrottlingRetryIntervalSeconds( _ throttlingRetryIntervalSeconds: TimeInterval ) {
229
- setInstanceUserDefaultsValue (
230
- throttlingRetryIntervalSeconds,
231
- forKey: kRCNUserDefaultsKeyNameCurrentThrottlingRetryInterval
232
- )
184
+ get {
185
+ instanceUserDefaults [
186
+ kRCNUserDefaultsKeyNameCurrentThrottlingRetryInterval
187
+ ] as? TimeInterval ?? 0
188
+ }
189
+ set {
190
+ setInstanceUserDefaultsValue (
191
+ newValue, forKey: kRCNUserDefaultsKeyNameCurrentThrottlingRetryInterval
192
+ )
193
+ }
233
194
}
234
195
235
196
/// The realtime retry count.
236
197
@objc public var realtimeRetryCount : Int {
237
- return instanceUserDefaults [ kRCNUserDefaultsKeyNameRealtimeRetryCount] as? Int ?? 0
238
- }
239
-
240
- /// Sets the realtime retry count.
241
- ///
242
- /// - Parameter realtimeRetryCount: The realtime retry count.
243
- @objc public func setRealtimeRetryCount( _ realtimeRetryCount: Int ) {
244
- setInstanceUserDefaultsValue (
245
- realtimeRetryCount,
246
- forKey: kRCNUserDefaultsKeyNameRealtimeRetryCount
247
- )
198
+ get { instanceUserDefaults [ kRCNUserDefaultsKeyNameRealtimeRetryCount] as? Int ?? 0 }
199
+ set { setInstanceUserDefaultsValue ( newValue, forKey: kRCNUserDefaultsKeyNameRealtimeRetryCount)
200
+ }
248
201
}
249
202
250
203
/// The realtime throttle end time.
251
204
@objc public var realtimeThrottleEndTime : TimeInterval {
252
- return instanceUserDefaults [ kRCNUserDefaultsKeyNameRealtimeThrottleEndTime] as? TimeInterval ??
253
- 0
254
- }
255
-
256
- /// Sets the realtime throttle end time.
257
- ///
258
- /// - Parameter throttleEndTime: The realtime throttle end time.
259
- @objc public func setRealtimeThrottleEndTime( _ throttleEndTime: TimeInterval ) {
260
- setInstanceUserDefaultsValue (
261
- throttleEndTime,
262
- forKey: kRCNUserDefaultsKeyNameRealtimeThrottleEndTime
263
- )
205
+ get {
206
+ instanceUserDefaults [ kRCNUserDefaultsKeyNameRealtimeThrottleEndTime] as? TimeInterval ?? 0
207
+ }
208
+ set {
209
+ setInstanceUserDefaultsValue (
210
+ newValue, forKey: kRCNUserDefaultsKeyNameRealtimeThrottleEndTime
211
+ )
212
+ }
264
213
}
265
214
266
215
/// The current realtime throttling retry interval in seconds.
267
216
@objc public var currentRealtimeThrottlingRetryIntervalSeconds : TimeInterval {
268
- return instanceUserDefaults [
269
- kRCNUserDefaultsKeyNameCurrentRealtimeThrottlingRetryInterval
270
- ] as? TimeInterval ??
271
- 0
272
- }
273
-
274
- /// Sets the current realtime throttling retry interval in seconds.
275
- ///
276
- /// - Parameter throttlingRetryIntervalSeconds: The current realtime throttling retry interval in
277
- /// seconds.
278
- @objc public func setCurrentRealtimeThrottlingRetryIntervalSeconds( _ throttlingRetryIntervalSeconds: TimeInterval ) {
279
- setInstanceUserDefaultsValue ( throttlingRetryIntervalSeconds,
280
- forKey: kRCNUserDefaultsKeyNameCurrentRealtimeThrottlingRetryInterval)
217
+ get {
218
+ instanceUserDefaults [
219
+ kRCNUserDefaultsKeyNameCurrentRealtimeThrottlingRetryInterval
220
+ ] as? TimeInterval ?? 0
221
+ }
222
+ set {
223
+ setInstanceUserDefaultsValue (
224
+ newValue, forKey: kRCNUserDefaultsKeyNameCurrentRealtimeThrottlingRetryInterval
225
+ )
226
+ }
281
227
}
282
228
283
229
/// Resets the user defaults.
0 commit comments