Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bithavoc/codablelocal

Extend UserDefaults to set and get methods that work with any Codable(Encodable & Decodable) conforming types
https://github.com/bithavoc/codablelocal

codable extensions ios json local macos persistence swift user-defaults

Last synced: about 2 months ago
JSON representation

Extend UserDefaults to set and get methods that work with any Codable(Encodable & Decodable) conforming types

Awesome Lists containing this project

README

        

# CodableLocal

[![Version](https://img.shields.io/cocoapods/v/CodableLocal.svg?style=flat)](https://cocoapods.org/pods/CodableLocal)
[![License](https://img.shields.io/cocoapods/l/CodableLocal.svg?style=flat)](https://cocoapods.org/pods/CodableLocal)
[![Platform](https://img.shields.io/cocoapods/p/CodableLocal.svg?style=flat)](https://cocoapods.org/pods/CodableLocal)

## Example

### `UserDefaults+Codable`

```swift
struct UserInfo : Codable {
let userId: String
}

...

let defaults = UserDefaults.standard
try defaults.set(object: UserInfo(userId: "id1"), forKey: "current-user")
let info = try defaults.get(objectType: UserInfo.self, forKey: "current-user")
```

## Requirements

* Swift 5 or above

## Installation

CodableLocal is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:

```ruby
pod 'CodableLocal'
```

## Author

bithavoc, [email protected]

## License

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