Swiftpack.co - stateman92/KeyValueStorage as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by stateman92.
stateman92/KeyValueStorage 0.0.2
Store any data on the device! 🧳
⭐️ 2
🕓 51 weeks ago
iOS macOS
.package(url: "https://github.com/stateman92/KeyValueStorage.git", from: "0.0.2")


Store any data on the device! 🧳


Add the following to Package.swift:

.package(url: "https://github.com/stateman92/KeyValueStorage", exact: .init(0, 0, 2))

Or add the package in Xcode.


import KeyValueStorage

struct CodablePage {
    let text: String

extension CodablePage: Codable {}

let coder = Coder()
let object = CodablePage(text: "Text")
let data: Data? = coder.encode(object, type: .json)
let storageData = UserDefaultsKeyValueStorage().do {
    let key = "KEY"
    $0.save(data, forKey: key)
    return $0.get(forKey: key)
let result: CodablePage? = coder.decode(storageData, type: .json)
// object.text == result?.text

For details see the Example app.


The library is well-tested with practically 100% coverage (96.0%).


Stars: 2
Last commit: 19 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Related Packages

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