CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

Encodable 1.0.0

Encodable 1.0.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jan 2016
SPMSupports SPM

Maintained by Jo Albright.



Encodable 1.0.0

Swiftly Encode & Decode for Archiving & JSON

Usage

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

struct Person: Encodable {

    var name: String?
    var age: Int = 0

    init() { }

    init(_ info: EncodedInfo) {

        name <-- info["name"]
        age <-- info["age"]

    }

}

Struct from Example project

struct Album: Encodable {

    var title: String?
    var artist: String?
    var albumImageURL: String?
    var albumImage: UIImage?
    var trackCount: Int?
    var collectionPrice: Double?

    init() { }

    init(_ info: EncodedInfo) {

        title <-- info["collectionName"]
        artist <-- info["artistName"]
        albumImageURL <-- info["artworkUrl100"]
        trackCount <-- info["trackCount"]
        collectionPrice <-- info["collectionPrice"]

    }

}

Requirements

This pod uses Inlinit (a pod that allows closure initalizers).

Installation

Encodable is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Encodable"

Encodable is also available through Swift Package Manager. Please take a look at the link to learn more about how to use SwiftPM.

import PackageDescription

let package = Package(
    name: "YOUR_PACKAGE_NAME",
    dependencies: [
        .Package(url: "https://github.com/joalbright/Encodable.git", majorVersion: 0)
    ]
)

Author

Jo Albright

License

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