How to process the response data of FBSDKGraphRequest in Swift 3
You can simply do it as follows:
let data:[String:AnyObject] = result as! [String : AnyObject]
print(data["first_name"]!)
Swift 3:
Safe unwrapping & Any
instead of AnyObject
if let data = result as? [String:Any] {
}
Swift 5 Code for question and issue and solution:
Implementation:
let graphRequest:GraphRequest = GraphRequest(graphPath: "me", parameters: ["fields":"first_name,email,picture.type(large)"])
graphRequest.start(completionHandler: { (connection, result, error) -> Void in
if ((error) != nil) {
print("Error: \(String(describing: error))")
}
else {
guard let rDic = result as? NSDictionary else {
SVProgressHUD.showError(withStatus: "facebook Did not allowed loading email, please set that while updating profile.")
return
}
print("rDic = ", rDic)
}
})
Output:
rDic = {
email = "[email protected]";
"first_name" = Mr. Me;
id = #################;
picture = {
data = {
height = 32;
"is_silhouette" = 0;
url = "https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=################&height=200&width=200&ext=################&hash=################";
width = 32;
};
};
}
P.S.: Thanks to KD and Bista their question and answer helped me figure this.