Latest 1.1.1
Homepage https://github.com/maxsokolov/AlamofireUnbox
License MIT
Platforms ios 8.0
Dependencies Alamofire, Unbox
Authors

Swift 2.2 compatible
CocoaPods compatible
Platform iOSLicense: MIT

An extension to Alamofire which converts json response data into swift objects using Unbox.

Features

  • [x] Support object response
  • [x] Support array response
  • [x] Support key path
  • [x] Informative errors

Getting Started

An example app is included demonstrating functionality.

Usage

Let’s say we have a json of github users which are represented as Unboxable model:

struct User: Unboxable {

    let login: String

    init(unboxer: Unboxer) {

        login = unboxer.unbox("login")
    }
}

You could easily download an array of users using Alamofire and map them to your Unboxable models:

Alamofire
    .request(.GET, "https://api.github.com/users", parameters: nil, encoding: .JSON, headers: nil)
    .responseUnboxArray { (response: Response<[User], AlamofireUnboxError>) in

        // response.result.value
    }

Similar for regular objects:

Alamofire
    .request(.GET, "https://api.github.com/users/maxsokolov", parameters: nil, encoding: .JSON, headers: nil)
    .responseUnboxObject { (response: Response<User, AlamofireUnboxError>) in

        // response.result.value
    }

Installation

CocoaPods

To integrate AlamofireUnbox into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'AlamofireUnbox'

Manual

Clone the repo and drag files from Sources folder into your Xcode project.

Requirements

  • iOS 8.0+
  • Xcode 7.0+
  • Alamofire 3.2+
  • Unbox 1.5+

License

MIT license. See LICENSE for details.

Latest podspec

{
    "name": "AlamofireUnbox",
    "module_name": "AlamofireUnbox",
    "version": "1.1.1",
    "homepage": "https://github.com/maxsokolov/AlamofireUnbox",
    "summary": "An Alamofire extension which converts json response data into swift objects using Unbox",
    "authors": {
        "Max Sokolov": "[email protected]"
    },
    "social_media_url": "https://twitter.com/max_sokolov",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Sources/*.swift",
    "source": {
        "git": "https://github.com/maxsokolov/AlamofireUnbox.git",
        "tag": "1.1.1"
    },
    "dependencies": {
        "Alamofire": [
            "~> 3.2"
        ],
        "Unbox": [
            "~> 1.5"
        ]
    }
}

Pin It on Pinterest

Share This