this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Swift 100.0%
6 1 0

Clone this repository

https://tangled.org/radmakr.com/StorageKit https://tangled.org/did:plc:aq5iwu4gjdcg2hq53llism3x/StorageKit
git@tangled.org:radmakr.com/StorageKit git@tangled.org:did:plc:aq5iwu4gjdcg2hq53llism3x/StorageKit

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

StorageKit#

Sometimes Core Data or SQLite are overkill for your app. In those situations, StorageKit is a great solution to save Codable objects to disk.

Install StorageKit#

StorageKit currently only supports installation via Swift Package Manager.

Add Package Dependency#

In Xcode, select File > Add Packages....

Specify the Repository#

Copy and paste the following into the search/input box. https://github.com/SparrowTek/StorageKit.git

Specify Options#

In the options for the StorageKit package, we recommend setting the Dependency Rule to Up to Next Major Version, and enter the current StorageKit version. Then, click Add Package.

Select the Package Products#

Select StorageKit, then click Add Package.

Getting started#

First import StorageKit

import StorageKit

For any Codable object save and retrieve from disk.

struct User: Codable {
    let name: String
    let id: Int
}

Store#

do {
    let user = User(name: "Thomas", id: 123)
    try Storage.store(user, to: .documents, as: "user.json")
} catch {
    // TODO: handle error
}

retrieve#

let user = Storage.retrieve("user.json", from: .documents, as: User.self)

delete#

do {
    try Storage.remove("user.json", from: .documents)
} catch {
    // TODO: handle error
}

does a file exist?#

let exists = Storage.fileExists("user.json", in: .documents)