Skip to content

Instantly share code, notes, and snippets.

@olivaresf
Created October 12, 2020 16:16
Show Gist options
  • Save olivaresf/a7589e7e88e3bdf1788561c2c95af642 to your computer and use it in GitHub Desktop.
Save olivaresf/a7589e7e88e3bdf1788561c2c95af642 to your computer and use it in GitHub Desktop.
final class UserDefaultsStorage: Storage {
let modelVersion: String
let key: String
init(withKey: String, modelVersion: String) {
key = withKey
self.modelVersion = modelVersion
}
// Saving Settings bundle store, from cache.
func store(settingsBundle: SettingsBundle) {
var data = storedMigrationData
data.settingsBundle = settingsBundle
save(storedData: data)
}
// Loading of the settings bundle
func loadSettingsBundle() -> SettingsBundle {
storedMigrationData.settingsBundle
}
// Save onboarding bundle
func store(onboardingBundle: OnboardingBundle) {
var data = storedMigrationData
data.onboardingBundle = onboardingBundle
save(storedData: data)
}
// Loading onboarding bundle
func loadOnboardingBundle() -> OnboardingBundle {
storedMigrationData.onboardingBundle
}
private var storedDataCache: MigrationData?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment