Cannot subscript a value of type [String: AnyObject]? with an index of type String

混江龙づ霸主 提交于 2019-12-23 21:05:44

问题


I know have many the same question but still cannot find the way to fix my error. Please see the image for more detail. I used Xcode 7 and swift 2.0

Edit: fcking the warning of Swift. finnaly (change?[NSKeyValueChangeNewKey]?.boolValue)! fixed the error


回答1:


change is an optional. Either unwrap the optional

let isCaptureStillImage = change![NSKeyValueChangeNewKey]!.boolValue

or use optional bindings

if let changeNewKey = change?[NSKeyValueChangeNewKey] {
  let isCaptureStillImage = changeNewKey.boolValue

...


来源:https://stackoverflow.com/questions/32711613/cannot-subscript-a-value-of-type-string-anyobject-with-an-index-of-type-stri

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!