Home

Awesome

UnboxedAlamofire

⚠️ DEPRECATED

UnboxedAlamofire is deprecated as well as Unbox is deprecated in favor of Swift’s built-in Codable API.


Build Status CocoaPods Compatible Carthage Compatible Platform

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

Features

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