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

AlamofireUnbox 1.1.1

AlamofireUnbox 1.1.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Aug 2016
SPMSupports SPM

Maintained by Max Sokolov.



 
Depends on:
Alamofire~> 3.2
Unbox~> 1.5
 

AlamofireUnbox

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

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.