Reputation: 1807
I'm going through old code updating to the new iOS and Swift version and thus Alamofire version and its been a giant headache thus far. I have this code which I've simplified
fileprivate func fetchOuttings(_ type: MyType, callback: ((Response<AnyObject, NSError>) -> ())?) {
/* ... */
Alamofire.request(url, method: .get, parameters: nil, encoding: JSONEncoding.default, headers: header).responseJSON(completionHandler: { response in
if let _callback = callback {
_callback(response)
}
})
}
In the function signature after the Swift3/Alamofire4 update I'm not getting 'Use of undeclared type Response' and I can't figure out how to fix this. I've been looking all through the Alamofire 4 migration but can't find anything. And one have ideas?
Upvotes: 3
Views: 688
Reputation: 5088
Now it has changed to DataResponse
as @Rob Napier said. as an example if your want responseString
it should look like this
DataResponse<String>
and also, it will handle any error in .failure
part. you have to follow more in new Alamoire
. better to refer their docs in github Alamofire and also, if you want to know abour new Router
class implemention go with StackOverflow Question.
Upvotes: 1
Reputation: 299285
Response<AnyObject, NSError>
is now DataResponse<Any>
. Take a look at the new implementation of responseJSON
.
Upvotes: 4