Skip to content

MaciejGad/CodableSaveLoad

Repository files navigation

CodableSaveLoad Build Status codecov

Sample save&load for Codable

Usage

Let assume that you have a some Dummy structure that is Codable:

struct Dummy: Codable {
    let text: String
}

now you can easily save to app document directory:

let dummy = Dummy(text: "This is an example")
dummy.save()
//or if you what to know when it finished:
dummy.save().done { _ in 
   print("💾 Saved!")
}.catch { error in 
   print("💣 \(error)")
}

you can load this data to strucutre again:

Dummy.load().done { dummy in 
   print(dummy.text)
}.catch { error in 
   print("💣 \(error)")
}

or you can delete the file:

Dummy.delete() 
//or
Dummy.delete().done { _ in 
  print("deleted")
}.catch { error in 
   print("💣 \(error)")
}

Installation

Use the CocoaPods.

Add to your Podfile

pod 'CodableSaveLoad'

and then call

pod install

and import

import CodableSaveLoad

Hall Of Fame

About

💾 Sample save&load for Codable

Resources

License

Stars

Watchers

Forks

Packages

No packages published