https://github.com/inloop/codablestore
Persistance providers for swift Codables
https://github.com/inloop/codablestore
Last synced: 10 months ago
JSON representation
Persistance providers for swift Codables
- Host: GitHub
- URL: https://github.com/inloop/codablestore
- Owner: inloop
- License: mit
- Created: 2018-02-14T17:01:32.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-09T14:17:13.000Z (almost 7 years ago)
- Last Synced: 2025-03-26T21:45:55.394Z (10 months ago)
- Language: Swift
- Homepage:
- Size: 660 KB
- Stars: 6
- Watchers: 18
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CodableStore
[](https://travis-ci.org/inloop/CodableStore)
[](http://cocoapods.org/pods/CodableStore)
[](http://cocoapods.org/pods/CodableStore)
[](http://cocoapods.org/pods/CodableStore)
## Example
`UserDefaults` as storage provider:
```
struct Company {
let name: String
}
let provider = UserDefaults.standard
let tesla = Company(name: "Tesla")
let companyKey = "somekey"
tesla.create(provider, key: companyKey).then { (company: Company?) -> Void in
// company: Company?
}
Company.read(provider, key: companyKey).then { company -> Void in
// company: Company?
}
```
`URLSession` as storage provider:
```
struct Post: Codable {
let title: String
let body: String
}
let provider = URLSession.shared
let url = URL(string: "http://jsonplaceholder.typicode.com/posts")!
let detailUrl = URL(string: "http://jsonplaceholder.typicode.com/posts/1")!
[Post].read(store, key: url).then { posts -> Void in
// posts: [Post]?
}
Post.read(store, key: url).then { post -> Void in
// post: Post?
}
let newPost = Port(title: "Foo", body: "Blah")
newPost.create(store, key: url).then { (post: Post?) -> Void in
// post: Post?
}
```
### URLSession custom URLRequest
## Custom provider
## Requirements
## Installation
CodableStore is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod 'CodableStore'
```
## Author
Jakub Knejzlik, jakub.knejzlik@inloop.eu
## License
CodableStore is available under the MIT license. See the LICENSE file for more info.