<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: [Obj-C v2] How to cancel requests? in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Obj-C-v2-How-to-cancel-requests/m-p/214794#M11016</link>
    <description>&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DBTask *task = [[client.filesRoutes downloadData:remotePath] setResponseBlock:^(DBFILESFileMetadata *metadata, DBFILESDownloadError *downloadError, DBRequestError *error, NSData *fileData) {
    // handle result
}];&lt;/PRE&gt;
&lt;PRE&gt;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];
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Apr 2017 20:55:04 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2017-04-05T20:55:04Z</dc:date>
    <item>
      <title>[Obj-C v2] How to cancel requests?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Obj-C-v2-How-to-cancel-requests/m-p/214786#M11015</link>
      <description>&lt;P&gt;If I follow the sample guidance, I do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;[[client.filesRoutes ...] setResponseBlock:...]&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I'm not sure how to cancel the request.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried doing something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DBTask *task = [client.filesRoutes ...];
[task setResponseBlock:...]&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then if I need to cancel, do [task cancel]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But then the task wouldn't execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:24:01 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Obj-C-v2-How-to-cancel-requests/m-p/214786#M11015</guid>
      <dc:creator>philipkd</dc:creator>
      <dc:date>2019-05-29T09:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: [Obj-C v2] How to cancel requests?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Obj-C-v2-How-to-cancel-requests/m-p/214794#M11016</link>
      <description>&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DBTask *task = [[client.filesRoutes downloadData:remotePath] setResponseBlock:^(DBFILESFileMetadata *metadata, DBFILESDownloadError *downloadError, DBRequestError *error, NSData *fileData) {
    // handle result
}];&lt;/PRE&gt;
&lt;PRE&gt;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];
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 20:55:04 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Obj-C-v2-How-to-cancel-requests/m-p/214794#M11016</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-04-05T20:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: [Obj-C v2] How to cancel requests?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Obj-C-v2-How-to-cancel-requests/m-p/215084#M11055</link>
      <description>Awesome, looks like it's working now. Not sure what I was doing wrong. Thanks!</description>
      <pubDate>Fri, 07 Apr 2017 21:41:33 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Obj-C-v2-How-to-cancel-requests/m-p/215084#M11055</guid>
      <dc:creator>philipkd</dc:creator>
      <dc:date>2017-04-07T21:41:33Z</dc:date>
    </item>
  </channel>
</rss>

