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

UnboxedAlamofire 2.0.4

UnboxedAlamofire 2.0.4

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Serhii Butenko.



 
Depends on:
Alamofire~> 4.1
Unbox~> 2.0
 

  • By
  • Serhii Butenko

UnboxedAlamofire




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

Features

  • Unit tested
  • Fully documented
  • Mapping response to objects
  • Mapping response to array of objects
  • Keypaths
  • Nested keypaths
  • For Swift 2.x use v. 1.x and swift2 branch
  • 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