Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alamofire + SwiftyJSON Compile Error after converting to Xcode 7

This line has always been working fine for me for making Alamofire Requests and getting the JSON response.

Alamofire.request(req).responseJSON() {
        (request, response, data, error) in

    // ....

}

After upgrading to XCode 7 and converting the Project to Swift 2.0, all the lines of code that have my Alamofire request are not showing this error:

'(_, _, _, _) -> Void' is not convertible to 'Response<AnyObject, NSError> -> Void'
like image 984
Lavvo Avatar asked Sep 22 '15 17:09

Lavvo


1 Answers

Found the answer in this link but it is in japanese. It seems this is the correct from now (taken from answer in link):

Alamofire.request(.GET, requestUrl).responseJSON {
   response in
    if response.result.isSuccess {
        let jsonDic = response.result.value as! NSDictionary
        let responseData = jsonDic["responseData"] as! NSDictionary
        self.newsDataArray = responseData["results"] as! NSArray
        self.table.reloadData()
    }            
}
like image 131
Braulio Miki Avatar answered Sep 19 '22 00:09

Braulio Miki