Home parse IOS FBSDKGraphRequest result using Swift4 JSONDecoder
Reply: 0

parse IOS FBSDKGraphRequest result using Swift4 JSONDecoder

user933
1#
user933 Published in July 23, 2018, 1:14 pm

the result of FBSDKGraphRequest is of type any and could be casting to NSDictionary, but how to convert it to Data object to be able to use this SWIFT4 feature

let jsonDecoder = JSONDecoder.init()
let fbModel = try? jsonDecoder.decode(FBModel.self, from: dataFromResult)

i'm try this but the result was nil as code comments

    FBSDKGraphRequest.init(graphPath: "me", parameters: ["fields":"email,name,id"]).start{ (connection, results, error) -> Void in
           let dataFromResult = NSKeyedArchiver.archivedData(withRootObject: results)
           let stringFromData = String.init(data: dataFromResult, encoding: String.Encoding.utf8)//return nil
           let jsonDecoder = JSONDecoder.init()
           let fbModel = try? jsonDecoder.decode(FBModel.self, from: dataFromResult)//fbModel nil
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.7265 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO