sunshinejr / SwiftyUserDefaults

Modern Swift API for NSUserDefaults
http://radex.io/swift/nsuserdefaults/static
MIT License
4.86k stars 366 forks source link

Stubbing and mocking #131

Closed kasyanov-ms closed 7 years ago

kasyanov-ms commented 7 years ago

When I have to inject UserDefaults, I do the following:

protocol UserDefaultsType
{
    func object(forKey defaultName: String) -> Any?
    func set(_ value: Any?, forKey defaultName: String)
}

extension UserDefaults: UserDefaultsType {  }

Are there any good practices to accomplish the same for SwiftyUserDefaults?

basememara commented 7 years ago

Check this out: https://twitter.com/johnsundell/status/855713943809032192

c-absshxuaa_9gi jpg-small