我正在尝试从swift 3.0中的数组访问json对象,在为模拟器编译时没有出错,但是当我再次为通用设备编译时,它开始在数组上给出错误不明确地使用'下标'< / strong>我尝试了很多解决方案,但没有成功,我是ios开发的新手,任何人都可以解决我的问题。这是代码 错误是在“?(这里是错误)[0]”
之后的第3行Alamofire.request(url, method: .get).responseJSON { response in
let result = response.result
if let result = result.value as? Dictionary<String,AnyObject>{
if let Response = result["Response"] as? Dictionary<String,AnyObject>{
if let View = Response["View"]?[0] as? Dictionary<String,AnyObject>{
if let Result = View["Result"]?[0] as? Dictionary<String,AnyObject> {
if let Location = Result["Location"] as? Dictionary<String,AnyObject> {
if let LinkInfo = Location["LinkInfo"] as? Dictionary<String,AnyObject> {
这是我试图解析的json
{
"Response": {
"MetaInfo": {
"Timestamp": "2017-07-02T08:58:17.016+0000",
"NextPageInformation": "2"
},
"View": [
{
"_type": "SearchResultsViewType",
"ViewId": 0,
"Result": [
{
"Relevance": 1,
"Distance": 6,
}]}]}]