Latest 0.3.0
Homepage https://github.com/susan335/UserDefaultsProxy
License MIT
Platforms ios 10.0
Authors

Version
License
Platform

It is wrapper for UserDefaults.
UserDefaultsProxy is Type-safety, and Testable.

Example

class AppSetting {

    // String value. It isn't optional. It's needs default value.
    static let userName = StringProxy(key: "userName", defaultValue: "unknown")

    // Optional int value.
    static let age = IntOptProxy(key: "age")

}

func doSomething() {
    let userName = AppSetting.userName.value
    let age = AppSetting.age.value
}

func updateAge(_ age: Int) {
    AppSetting.age.value = age
}

Keys

There is no rule in Key. But do not duplicate.
if you would like to duplicate key check in debug build…

#if DEBUG
    DuplicateKeyChecker.isCheckDuplicateKey = true
#endif

UnitTest

If you would like to test for UserDefaults, You can use mock objects.

class Tests: XCTestCase {

    override func setUp() {
        super.setUp()
        UserDefaultsContainer.resolve = {
            return UserDefaultsMock()
        }
    }

A new instance of UserDefaults mock is created each time it is executed.

Installation

UserDefaultsProxy is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "UserDefaultsProxy"

Author

watanave, [email protected]

License

UserDefaultsProxy is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "UserDefaultsProxy",
    "version": "0.3.0",
    "summary": "UserDefaults Swift wrapper library.",
    "description": "TODO: Add long description of the pod here.",
    "homepage": "https://github.com/susan335/UserDefaultsProxy",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "watanave": "[email protected]"
    },
    "source": {
        "git": "https://github.com/susan335/UserDefaultsProxy.git",
        "tag": "0.3.0"
    },
    "social_media_url": "https://twitter.com/Susan_jacko",
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "UserDefaultsProxy/Classes/**/*"
}

Pin It on Pinterest

Share This