swift 开发过程中犯过的错误记录

1.嵌套数组使用过程中的错误

错误提示:Cannot assign to immutable value of type 'String' Could not find member 'subscript' 如下图

swift 开发过程中犯过的错误记录_第1张图片

当然这样写问题很大的,这里要说的重点是第一重字典后面的as后面应为“!”,而不能为"?",正确写法如下:

//                  //与下面的方法等价
//                  var imgsDic = dict["images"] as! NSDictionary
//                  model.movImg = imgsDic["large"] as? String
                    model.movImg = (dict["images"] as! NSDictionary)["large"] as? String


你可能感兴趣的:(ios,swift,错误)