/EasyUserDefault

Easy and elegant uses UserDefault.

Primary LanguageSwiftMIT LicenseMIT

EasyUserDefault

Swift Cocoapods Compatible

Easy and elegant uses UserDefault.

Requirements

  • iOS 8.0+
  • Swift 3.0+

Installation

CocoaPods

available on CocoaPods. Just add the following to your project Podfile:

pod 'EasyUserDefault'
use_frameworks!

import the library in all files where you use it:

import EasyUserDefault

Usage

See the code snippet below for an example of how to implement

Create

let storedObject = EasyUserDefault(key: "yourIdentifier")

Store value

  • supported: String, Integer, Dictionary, Array, Boolean
storedObject.store(yourValue)

Get value

storedObject.storedRawValue()
storedObject.storedRawValue<String>()
let dict = try? storedObject.storedValue<[String, Any]>()

Cool feature

storedObject.string           // Optional string
storedObject.stringValue      // Non-optional string
storedObject.dictionary       // Optional dictionary
storedObject.dictionaryValue  // Non-optional dictionary
storedObject.array            // Optional array
storedObject.arrayValue       // Non-optional array
storedObject.bool             // Optional bool
storedObject.boolValue        // Non-optional bool

Check

storedObject.exist()

Author

Vincent Lin

License

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