Last active
January 24, 2025 23:41
-
-
Save colinfwren/0da3628f5d9f694497ae89140f95b1d6 to your computer and use it in GitHub Desktop.
Mock of UserDefaults
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MockUserDefault: UserDefaults { | |
var persistedValue: Data? = nil | |
var persistedKey: String? = nil | |
override func set(_ value: Any?, forKey defaultName: String) { | |
persistedValue = value as? Data | |
persistedKey = defaultName | |
} | |
override func object(forKey defaultName: String) -> Any? { | |
return persistedValue | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment