我正在用最新的Swift3重寫我的圖形請求。我遵循這裏找到的指南 - https://developers.facebook.com/docs/swift/graph。使用Swift3的Facebook圖形請求 -
fileprivate struct UserProfileRequest: GraphRequestProtocol {
struct Response: GraphResponseProtocol {
init(rawResponse: Any?) {
// Decode JSON into other properties
}
}
let graphPath: String = "me"
let parameters: [String: Any]? = ["fields": "email"]
let accessToken: AccessToken? = AccessToken.current
let httpMethod: GraphRequestHTTPMethod = .GET
let apiVersion: GraphAPIVersion = .defaultVersion
}
fileprivate func returnUserData() {
let connection = GraphRequestConnection()
connection.add(UserProfileRequest()) {
(response: HTTPURLResponse?, result: GraphRequestResult<UserProfileRequest.Response>) in
// Process
}
connection.start()
不過,我在connection.add方法收到此錯誤:
Type ViewController.UserProfileRequest.Response does not conform to protocol GraphRequestProtocol.
我似乎無法想出解決辦法是什麼改變這裏。看起來開發者指南在Swift3上並不是最新的,但我不確定這是否是問題所在。
有人能夠看到這裏有什麼問題嗎?
謝謝。
如何獲取圖片?responseDictionary [「picture」] as Any。我正在獲得另一個數組 –