Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swift 3: Type 'Any?' has no subscript members

I keep getting this error for my graph requests??

Type 'Any?' has no subscript members

the error points at result.... this only happened when I converted to swift 3... anybody????

 let nextrequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me/friends", parameters: ["fields": "name, id, gender"], httpMethod: "GET")
            nextrequest.start { (connection, result, error) -> Void in
                guard let listOfFriends = result["data"] as? [AnyObject] else {
                    return
                }
            }
        }
like image 795
slimboy Avatar asked Sep 17 '16 16:09

slimboy


1 Answers

Try this

let nextrequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath:"me/friends", parameters: ["fields": "name, id, gender"], httpMethod: "GET")
    nextrequest.start { (connection, result, error) -> Void in
         guard let result = result as? [String:[AnyObject]], let listOfFriends = result["data"]  else {
        return
    }
  }
}
like image 158
Jans Avatar answered Sep 21 '22 23:09

Jans