Skip to content

rizwankce/Storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swift Storage

CI Status Version License Platform

If you are using Coadble protocol from Swift 4 and needs an easy way to store and retrieve your objects, You are in the right place. Swift Storage is a simple extension to store/retrieve your Coadble objects.

Features

  • Store Codable objects
  • Retrieve stored Coadble objects
  • Store Locations
  • Cache
  • Documents
  • User Default
  • CloudKit
  • NSUbiquitousKeyValueStore
  • Name Spaced Stores
  • Comprehensive Unit and Integration Test Coverage
  • Complete Documentation

Usage

Considering you have a Coadble Job struct like below

struct Job: Codable {
    let company: String
    let position: String
    let description: String
    let url: String
}

To save or retrieve array of Job

// Create a instance of `Storage` with a type and file name
let storage: Storage<[Job]> = Storage(storageType: .document, filename: "remote-jobs.json")

// To Save array of `Job`
storage.save([job1, job2])

// To retrieve stored values of jobs
let jobs = storage.storedValue

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • Xcode 9.0+
  • Swift 4

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command in terminal:

$ gem install cocoapods

To integrate Swift Storage into your Xcode project using CocoaPods, simply add the following line to your Podfile:

pod 'SwiftStorage'

Contributing

If you like to contribute to this project, feel free to send PR or raise issues.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Credits

The idea of Swift Storage is orginally came from Ben Scheirman from NSScreenCast and most of the code is inspired from one of his series and extended a little with more options.

License

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