Swiftpack.co - mobillium/MobilliumUserDefaults as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by mobillium.
mobillium/MobilliumUserDefaults 2.0.1
UserDefaults helper for iOS apps.
⭐️ 10
🕓 2 years ago
iOS
.package(url: "https://github.com/mobillium/MobilliumUserDefaults.git", from: "2.0.1")

MobilliumUserDefaults

Build Status Version License Platform

Requirements

  • iOS 8.0+

Installation

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

pod 'MobilliumUserDefaults'

Usage

Set defaults(optional):

Defaults = UserDefaults.standard // or default is UserDefaults.standard

Create you DefaultsKey:

import MobilliumUserDefaults

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

Save value:

let value = "string"
DefaultsKey.stringKey.value = value

Get value:

let value = DefaultsKey.stringKey.value

Check value:

if DefaultsKey.stringKey.has { 
    //
}

Remove value:

DefaultsKey.stringKey.value = nil
//or
DefaultsKey.stringKey.remove()

Remove all values:

Defaults.removeAll()

License

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

GitHub

link
Stars: 10
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

add SPM support
2 years ago

add Swift Package Manager support

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics