Skip to content

Commit

Permalink
Merge pull request #2 from ivanrein/fix-force-unwrap
Browse files Browse the repository at this point in the history
fix force unwrapping
  • Loading branch information
Lenhador authored Sep 22, 2021
2 parents 11df0e7 + dc825ae commit 29b3872
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Sources/Skylab/UserDefaultsStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ class UserDefaultsStorage: Storage {
func load() {
mapLock.withCriticalScope {
do {
let data = userDefaults.value(forKey: self.sharedPrefsKey) as! Data
let loaded = try JSONDecoder().decode([String:Variant].self, from: data)
for (key, value) in loaded {
map[key] = value
if let data = userDefaults.value(forKey: self.sharedPrefsKey) as? Data {
let loaded = try JSONDecoder().decode([String:Variant].self, from: data)
for (key, value) in loaded {
map[key] = value
}
}
} catch {
print("[Experiment] load failed: \(error)")
Expand Down

0 comments on commit 29b3872

Please sign in to comment.