Ios 如何使用Swift 3从Facebook SDK下载照片?

Ios 如何使用Swift 3从Facebook SDK下载照片?,ios,facebook-graph-api,swift3,Ios,Facebook Graph Api,Swift3,在iOS应用程序中下载用户配置文件照片时发生崩溃: let dataPhoto = try! Data(contentsOf: photoURL, options: .mappedIfSafe) (lldb) po photoURL ▿ https:/scontent.xx.fbcdn.net/v/t1.0-1/p200x200/13418946_10208553701714177_3969269576626117653_n.jpg%3Foh=add39246ec9693ecead0529ec

在iOS应用程序中下载用户配置文件照片时发生崩溃:

let dataPhoto = try! Data(contentsOf: photoURL, options: .mappedIfSafe)

(lldb) po photoURL
▿ https:/scontent.xx.fbcdn.net/v/t1.0-1/p200x200/13418946_10208553701714177_3969269576626117653_n.jpg%3Foh=add39246ec9693ecead0529ecbbbfc53&oe=5862D7ED -- file:///

fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=260 "The file “13418946_10208553701714177_3969269576626117653_n.jpg?oh=add39246ec9693ecead0529ecbbbfc53&oe=5862D7ED” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/https:/scontent.xx.fbcdn.net/v/t1.0-1/p200x200/13418946_10208553701714177_3969269576626117653_n.jpg?oh=add39246ec9693ecead0529ecbbbfc53&oe=5862D7ED, NSUnderlyingError=0x170246000 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-800.0.46.2/src/swift/stdlib/public/core/ErrorType.swift, line 178
2016-10-04 12:48:14.317003 Movie Buffs[2722:1318691] fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=260 "The file “13418946_10208553701714177_3969269576626117653_n.jpg?oh=add39246ec9693ecead0529ecbbbfc53&oe=5862D7ED” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/https:/scontent.xx.fbcdn.net/v/t1.0-1/p200x200/13418946_10208553701714177_3969269576626117653_n.jpg?oh=add39246ec9693ecead0529ecbbbfc53&oe=5862D7ED, NSUnderlyingError=0x170246000 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-800.0.46.2/src/swift/stdlib/public/core/ErrorType.swift, line 178
发生了什么事?早期的斯威夫特成功了

使用该方法得到了相同的结果:

URLSession.shared.dataTask(with: photoURL) {(dataPhoto, response, error) in
而不是

URL(fileURLWithPath: profilePictureURLStr)
需要URL像这样构建:

let photoURL = URL(string: profilePictureURLStr)!