lee
lee

Reputation: 8105

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

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

enter image description here

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

Upvotes: 3

Views: 3783

Answers (1)

vadian
vadian

Reputation: 285082

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

...

Upvotes: 6

Related Questions