Swiftpack.co - Package - v-braun/UserDefaultsEx

UserDefaultsEx

Making UserDefaults great (again?)

By v-braun - viktor-braun.de.

Build Status PR welcome

Description

Help you to store Codable Objects within UserDefaults.
Just define your properties and UserDefaultsEx will take care of the encoding and decoding process.

Installation

.package(url: "https://github.com/v-braun/UserDefaultsEx", from: "1.0.0")

Usage

struct TestSetting : Codable{
    var prop1 = ""
    var prop2 = ""
}

extension UserDefaults{
    @JsonUserDefault(storeIn: UserDefaults.standard, withKey: "mySettings", defaults: TestSetting())
    static var mySettings : TestSetting
}

// somewhere:

let settings = UserDefaults.mySettings // will read the settings

settings.prop1 = "hello"
settings.prop2 = "world"

UserDefaults.mySettings = settings // will write the settings

Authors

image
v-braun

Contributing

Make sure to read these guides before getting started:

License

UserDefaultsEx is available under the MIT License. See LICENSE for details.

Github

link
Stars: 0

Dependencies

Used By

Total: 0

Releases

- 2020-01-08 16:34:29