Alamofire可以根据响应的内容类型调用不同的响应序列化程序吗?

时间:2015-01-13 15:27:52

标签: swift alamofire swifty-json

根据我们在请求中发送的情绪和信息,我们的服务器可能会发回内容类型为text/plain的空体204响应或其他类似400系列响应的application/json身体详细说明错误。我们该如何处理?

我们想到这样的事情:

Alamofire.request(request)
    .responseString({ (request, response, string, error) -> Void in
        // Happy dance
    })
    .responseSwiftyJSON({ (request, response, json, error) -> Void in
        // Parse the error out of the json response and inform the user
    })

...但似乎所有链式响应处理程序都已执行。有没有办法说"只针对特定的错误类型调用这个"或者"只针对特定的响应代码调用此代码"?

我们是否遗漏了有关Alamofire如何运作的信息?

0 个答案:

没有答案