swift - List expects 3 elements but I don't know from where third comes -
so trying follow tutorial oauth 2.0 here. under section "oauthswift embedded web view". whole function:
// 1 create oauth2swift object let oauthswift = oauth2swift( consumerkey: "your_google_drive_client_id", // 2 enter google app settings consumersecret: "your_google_drive_client_secret", authorizeurl: "https://accounts.google.com/o/oauth2/auth", accesstokenurl: "https://accounts.google.com/o/oauth2/token", responsetype: "code" ) // 3 trigger oauth2 dance oauthswift.authorizewithcallbackurl( nsurl(string: "com.raywenderlich.incognito:/oauth2callback")!, scope: "https://www.googleapis.com/auth/drive", // 4 scope state: "", success: { credential, response in var parameters = [string: anyobject]() // 5 embedded http layer , upload oauthswift.client.postimage( "https://www.googleapis.com/upload/drive/v2/files", parameters: parameters, image: self.snapshot(), success: { data, response in let jsondict: anyobject! = nsjsonserialization.jsonobjectwithdata(data, options: nil, error: nil) self.presentalert("success", message: "successfully uploaded!") }, failure: {(error:nserror!) -> void in self.presentalert("error", message: error!.localizeddescription) }) }, failure: {(error:nserror!) -> void in self.presentalert("error", message: error!.localizeddescription) })
i error on point 4 (scope) list filled:
success: { credential, response in var parameters = [string: anyobject]()
it says expects 3 arguments specified two. appreciated.
it may 2 arguments valid when tutorial made (or last updated), , requires 3 arguments. so, replace:
success: { credential, response in var parameters = [string: anyobject]() ...
with:
success: { credential, response, parameters in ...
the let jsondict
line follows old format, , doesn't handle errors, change to:
do { let jsondict = try nsjsonserialization.jsonobjectwithdata(data, options: []) as! [string: anyobject] // , replace [string: anyobject] json format. } catch { // error handling here }
Comments
Post a Comment