Swift
Swift
Delete a Task from a Task List
See more Google Tasks Examples
Demonstrates how to delete a Google task from a 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
http.setUrlVar(name: "tasklist", value: "MDM4MzQ4NTA3NDQwMDUxMzQ2OTQ6NzAwOTA4MDA1NzU2ODYwMzow")
http.setUrlVar(name: "task", value: "MDM4MzQ4NTA3NDQwMDUxMzQ2OTQ6NzAwOTA4MDA1NzU2ODYwMzoxMTg0MzQxMTkzMjM2MDY1")
let resp = CkoHttpResponse()!
success = http.httpNoBody(verb: "DELETE", url: "https://www.googleapis.com/tasks/v1/lists/{$tasklist}/tasks/{$task}", 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)")
}