Using Alamofire-SwiftyJSON , the error handling is the same:
.responseSwiftyJSON({ (request, response, json, error) -> Void in if let error = error { print("Received error \(error)") return } else { print("Received json response \(json)") } }
but now error is ErrorType instead of NSError .
Using simple Alamofire and iOS JSON, the response and error are unified as a result of type Result<AnyObject> , you need to expand the result:
.responseJSON { request, response, result in switch result { case .Success(let value): print("Received response \(value)") case .Failure(_, let error): print("Received error \(error)") }
source share