2015-10-09 75 views
0

我不断收到此错误:Alamofire雨燕2.0 JSON响应

'(_, _, _, _) -> Void' is not convertible to 'Response<AnyObject, NSError> -> Void' 

我看了很多地方,并试图改变,但别的地方给我的错误。

Alamofire.request(.GET, "http://example.com/test.php", parameters: ["username": usernamep]).responseJSON { (request, response, json, error) in 
     if (json != nil) { 
      var jsonObj = JSON(json!) 
      if let data = jsonObj["flist"].arrayValue as [JSON]?{ 
       datasMentions = data 
      .... 
      } 
     } 
+1

那么你不应该有'(_,_,_,_)',它们应该是'(respond,json,error,_)'这些是响应。 – Xrait

回答

0

经过几次试验,我明白了。

Alamofire.request(.GET,"http://example.com/test.php", parameters: ["username": usernamep]) 
     .responseJSON { response in 

      if let json = response.result.value { 
     var jsonObj = JSON(json!) 
     if let data = jsonObj["flist"].arrayValue as [JSON]?{ 
      datasMentions = data 
     .... 
     } 
      } 
    }