MSAUserDefaults
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 = trueGet a 'value' using 'key':
let boolKey = DefaultsKey.boolKey.valueRemoves a value using 'key':
DefaultsKey.boolKey.remove()Check a value:
let has = DefaultsKey.boolKey.hasRemoves 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.