2015-10-09 73 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 
     .... 
     } 
      } 
    }