Swift
Swift
Delete a Task List
See more Google Tasks Examples
Demonstrates how to delete a Google task list.Chilkat Swift Downloads
func chilkatTest() {
var success: Bool = false
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// Get the previously obtained access token.
// See Get Google Tasks Access Token.
let fac = CkoFileAccess()!
var accessToken: String? = fac.readEntireTextFile(path: "qa_data/tokens/googleTasks.txt", charset: "utf-8")
if fac.lastMethodSuccess == false {
print("\(fac.lastErrorText!)")
return
}
let http = CkoHttp()!
http.authToken = accessToken
// Delete the task list with this ID: MDM4MzQ4NTA3NDQwMDUxMzQ2OTQ6OTk5Njk3NjkxNzg4Nzg2NDow
http.setUrlVar(name: "taskListId", value: "MDM4MzQ4NTA3NDQwMDUxMzQ2OTQ6OTk5Njk3NjkxNzg4Nzg2NDow")
let resp = CkoHttpResponse()!
success = http.httpNoBody(verb: "DELETE", url: "https://www.googleapis.com/tasks/v1/users/@me/lists/{$taskListId}", response: resp)
if success == false {
print("\(http.lastErrorText!)")
return
}
// Show the response body. (empty for success)
print("\(resp.bodyStr!)")
// Examine the response status code. (204 = success)
print("response status code: \(resp.statusCode.intValue)")
}