【问题标题】:Alamofire Swift 2.0 json responseAlamofire Swift 2.0 json 响应
【发布时间】:2015-10-09 14:47:31
【问题描述】:

我不断收到此错误:

 '(_, _, _, _) -> 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
             ....
            }
        }

【问题讨论】:

  • 嗯,你不应该有(_, _, _, _ ),他们应该是(respond, json, error, _) 这些是回复。

标签: swift swift2 alamofire


【解决方案1】:

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

    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
         ....
        }
            }
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-09
    • 1970-01-01
    • 2021-07-22
    • 1970-01-01
    • 2021-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多