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
Post a Comment