MSAUserDefaults 2.0.0

MSAUserDefaults 2.0.0

Maintained by aslanmehmetsalih.



MSAUserDefaults

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 8.0+

Installation

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

pod 'MSAUserDefaults'

Usage

Create your keys:

import MSAUserDefaults

extension DefaultsKey {
    static let boolKey = Key<Bool>(key: "boolKey")
    static let stringKey = Key<String>(key: "stringKey")
    static let intKey = Key<Int>(key: "intKey")
    static let arrayKey = Key<[String]>(key: "arrayKey")
}

Saves a 'value' using 'key':

DefaultsKey.boolKey.value = true

Get a 'value' using 'key':

let boolKey = DefaultsKey.boolKey.value

Removes a value using 'key':

DefaultsKey.boolKey.remove()

Check a value:

let has = DefaultsKey.boolKey.has

Removes all values from user defaults:

Defaults.removeAll()

Set your UserDefaults(optional):

Defaults = UserDefaults(suiteName: "yourSuitName")!

License

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