Reputation: 35040
Earlier I tried to access like this:
let gr2 : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id,picture.width(198).height(198)"])
gr2.start(completionHandler: { (connection, result2, error) -> Void in
let data = result2 as! [String : AnyObject]
let _loggedInUserSettingRecordName = data["id"] as? String // (forKey: "id") as? String
let profilePictureURLStr = data["picture.data.url"] as? String
But profilePictureURLStr
is nil now. What is different with Swift 3?
I can see url info is part of it:
(lldb) po result2
▿ Optional<Any>
▿ some : 2 elements
▿ 0 : 2 elements
- .0 : id
- .1 : 10208273026137463
▿ 1 : 2 elements
- .0 : picture
▿ .1 : 1 element
▿ 0 : 2 elements
- .0 : data
▿ .1 : 4 elements
▿ 0 : 2 elements
- .0 : is_silhouette
- .1 : 0
▿ 1 : 2 elements
- .0 : height
- .1 : 200
▿ 2 : 2 elements
- .0 : url
- .1 : https://scontent.xx.fbcdn.net/v/t1.0-1/p200x200/13418946_10208553701714177_3969269576626117653_n.jpg?oh=add39246ec9693ecead0529ecbbbfc53&oe=5862D7ED
▿ 3 : 2 elements
- .0 : width
- .1 : 200
Upvotes: 3
Views: 2331
Reputation: 16074
Also this way works in Swift 3:
if let picture = data["picture"] as? Dictionary<String,Any> {
if let data = picture["data"] as? Dictionary<String,Any> {
if let pictureUrl = data["url"] as? String {
dict["remote_main_image_url"] = pictureUrl
}
}
}
Upvotes: 0
Reputation: 35040
I tried many possibility, and this way you can get the url:
let profilePictureURLStr = (data["picture"]!["data"]!! as! [String : AnyObject])["url"]
Upvotes: 3