Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
philipkd
9 years agoCollaborator | Level 8
[Obj-C v2] How to cancel requests?
If I follow the sample guidance, I do this:
[[client.filesRoutes ...] setResponseBlock:...]
But I'm not sure how to cancel the request.
I tried doing something like this:
...
- 9 years ago
Calling cancel on the task object is the right way to cancel the request. I'm not sure what you mean when you say "the task wouldn't execute". That is the expected behavior once you call cancel.
Also, you can use setResponseBlock on the same line as where you retrieve the task object, in case that's the issue you're concerned about. For example:
DBTask *task = [[client.filesRoutes downloadData:remotePath] setResponseBlock:^(DBFILESFileMetadata *metadata, DBFILESDownloadError *downloadError, DBRequestError *error, NSData *fileData) { // handle result }];BOOL shouldCancel = true; // to be determined by something in your app, e.g., the user hitting a "Cancel" button if (shouldCancel) { NSLog(@"Cancelling."); [task cancel]; }
Greg-DB
Dropbox Community Moderator
9 years agoCalling cancel on the task object is the right way to cancel the request. I'm not sure what you mean when you say "the task wouldn't execute". That is the expected behavior once you call cancel.
Also, you can use setResponseBlock on the same line as where you retrieve the task object, in case that's the issue you're concerned about. For example:
DBTask *task = [[client.filesRoutes downloadData:remotePath] setResponseBlock:^(DBFILESFileMetadata *metadata, DBFILESDownloadError *downloadError, DBRequestError *error, NSData *fileData) {
// handle result
}];
BOOL shouldCancel = true; // to be determined by something in your app, e.g., the user hitting a "Cancel" button
if (shouldCancel) {
NSLog(@"Cancelling.");
[task cancel];
}
- philipkd9 years agoCollaborator | Level 8Awesome, looks like it's working now. Not sure what I was doing wrong. Thanks!
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!