Skip to content

Commit

Permalink
Add assertion for invalid groupName (#69)
Browse files Browse the repository at this point in the history
This working depends on your entitlements configuration. This assert
lets you fail faster if this is somehow invalid
  • Loading branch information
keith authored Aug 10, 2020
1 parent 5b05b5c commit 391aade
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/TimeStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public struct TimeStorage {
case .standard:
self.userDefaults = .standard
case .appGroup(let groupName):
self.userDefaults = UserDefaults(suiteName: groupName) ?? .standard
let sharedDefaults = UserDefaults(suiteName: groupName)
assert(sharedDefaults != nil, "Could not create UserDefaults for group: '\(groupName)'")
self.userDefaults = sharedDefaults ?? .standard
}
}
}

0 comments on commit 391aade

Please sign in to comment.