Latest 0.0.1
Homepage https://github.com/looseyi/SwiftUserDefaults
License MIT
Platforms ios 8.0
Authors

SwiftUserDefault, which is just wrap NSUserDefaults, make you easy to use.

struct TestUserDefault {
    static let stringTest = UserDefaultsItem<String>("stringTest")
    static let boolTest = UserDefaultsItem<Bool>("boolTest")
    static let intTest = UserDefaultsItem<Int>("intTest")
    static let floatTest = UserDefaultsItem<Float>("floatTest")
    static let doubleTest = UserDefaultsItem<Double>("doubleTest")
    static let dataTest = UserDefaultsItem<Data>("dataTest")
    static let dateTest = UserDefaultsItem<Date>("dateTest")
    static let intArrayTest = UserDefaultsItem<[Int]>("intArrayTest")
    static let stringArrayTest = UserDefaultsItem<[String]>("stringArrayTest")
    static let dataArrayTest = UserDefaultsItem<[Data]>("dataArrayTest")
    static let dictionaryTest = UserDefaultsItem<[String : Int]>("dictionary<String : Int>Testionary")
}

In your project, use can declear your store type, like above, UserDefaultsItem would synchronize it once you set newValue, if newValue is nil, the key’s value would be remove from NSUserDefaults.

set value

 TestUserDefault.stringTest.value = "I'am test"

get value

 let value = TestUserDefault.stringTest.value // will be "I'am test"

Install

pod SwiftUserDefault

Latest podspec

{
    "name": "SwiftUserDefault",
    "version": "0.0.1",
    "summary": "SwiftUserDefaults wrap NSUserDefaults, easy to use",
    "description": "SwiftUserDefaults is a wrapper, with it you can't use it as easy as you can, just like the Notification declear.",
    "homepage": "https://github.com/looseyi/SwiftUserDefaults",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Edmond": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/looseyi/SwiftUserDefaults.git",
        "tag": "0.0.1"
    },
    "source_files": [
        "Source",
        "Source/**/*.{swift}"
    ],
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This