metatext-app-ios-iphone-ipad/ServiceLayer/Sources/ServiceLayerMocks/MockUserDefaults.swift

22 lines
566 B
Swift
Raw Normal View History

2020-08-03 00:23:01 +02:00
// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
2020-11-09 07:22:20 +01:00
public final class MockUserDefaults: UserDefaults {
2020-08-31 20:57:02 +02:00
public convenience init() {
2020-08-03 00:23:01 +02:00
self.init(suiteName: Self.suiteName)!
}
2020-08-31 20:57:02 +02:00
public override init?(suiteName suitename: String?) {
2020-08-03 00:23:01 +02:00
guard let suitename = suitename else { return nil }
UserDefaults().removePersistentDomain(forName: suitename)
super.init(suiteName: suitename)
}
}
2020-08-09 03:29:05 +02:00
private extension MockUserDefaults {
2020-08-31 20:57:02 +02:00
private static let suiteName = "com.metabolist.metatext.mock-user-defaults"
2020-08-03 00:23:01 +02:00
}