swift 3类型'Any'没有下标成员?

时间:2017-05-02 11:15:46

标签: swift

我收到错误解析远程JSON数组,如何解决这个问题?

  

类型'Any'没有下标成员

代码

do {
    if let json = response.result.value {
        //print("Server JSON Response : \(json)")

        if let countries = json["Countries"] as? [String: Any] {
            for country in countries {
                if let couname = country["countryname"] as? [AnyObject] {
                    country_names.append(couname)
                }

                if let coucode = country["code"] as? [AnyObject] {
                    country_codes.append(coucode)
                }

            }
        }


    }

  } catch let parseError {
       print("Hioston we have problem \(parseError) ")
}

1 个答案:

答案 0 :(得分:0)

Typecast回复:

if let json = response.result.value as? [String:AnyObject]{..}
相关问题