Latest 2.0.4
Homepage https://github.com/serejahh/UnboxedAlamofire
License MIT
Platforms ios 8.0, osx 10.11, watchos 2.0, tvos 9.0
Dependencies Alamofire, Unbox
Authors

Build Status
CocoaPods Compatible
Carthage Compatible
Platform

Alamofire + Unbox: the easiest way to download and decode JSON into swift objects.

Features

  • [x] Unit tested
  • [x] Fully documented
  • [x] Mapping response to objects
  • [x] Mapping response to array of objects
  • [x] Keypaths
  • [x] Nested keypaths
  • [x] For Swift 2.x use v. 1.x and swift2 branch
  • [x] For Swift 3.x use v. 2.x

Usage

Objects you request have to conform Unboxable protocol.

Get an object

Alamofire.request(url, method: .get).responseObject { (response: DataResponse<Candy>) in
    // handle response
    let candy = response.result.value

    // handle error
    if let error = response.result.error as? UnboxedAlamofireError {
        print("error: (error.description)")
    }
}

Get an array

Alamofire.request(url, method: .get).responseArray { (response: DataResponse<[Candy]>) in
    // handle response
    let candies = response.result.value

    // handle error
    if let error = response.result.error as? UnboxedAlamofireError {
        print("error: (error.description)")
    }
}

KeyPath

Also you can specify a keypath in both requests:

Alamofire.request(url, method: .get).responseObject(keyPath: "response") { (response: DataResponse<Candy>) in
    // handle response
    let candy = response.result.value

    // handle error
    if let error = response.result.error as? UnboxedAlamofireError {
        print("error: (error.description)")
    }
}

Installation

CocoaPods

pod 'UnboxedAlamofire', '~> 2.0'

Carthage

github "serejahh/UnboxedAlamofire" ~> 2.0

Latest podspec

{
    "name": "UnboxedAlamofire",
    "version": "2.0.4",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "summary": "Alamofire + Unbox: the easiest way to download and decode JSON into swift objects.",
    "homepage": "https://github.com/serejahh/UnboxedAlamofire",
    "authors": {
        "Serhii Butenko": "[email protected]"
    },
    "source": {
        "git": "https://github.com/serejahh/UnboxedAlamofire.git",
        "tag": "2.0.4"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.11",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "source_files": "UnboxedAlamofire/**/*.swift",
    "dependencies": {
        "Alamofire": [
            "~> 4.1"
        ],
        "Unbox": [
            "~> 2.0"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This