ios - Type Any has no subscript members Swift 3.0 -


trying convert function make swift 3.0 compatible. had change parameter json anyobject any:

fileprivate func checkforauthorizationfailure(_ json: any) -> bool {          let responsemessage = json["response"]! as? string         if responsemessage == "unauthorized. invalid token or email." {             return true         }          return false     } 

however @ line: let responsemessage = json["response"]! as? string getting error: "type has no subscript members". doing wrong here?

you have cast anyobject before using subscript.

fileprivate func checkforauthorizationfailure(_ json: any) -> bool {      let responsemessage = (json anyobject)["response"]! as? string     if responsemessage == "unauthorized. invalid token or email." {         return true     }      return false } 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -