<?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: DBRpcTask response block not called. in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/DBRpcTask-response-block-not-called/m-p/225490#M12246</link>
    <description>&lt;P&gt;Here is the code. &amp;nbsp;I tried to make it as minimal as possible but I think the pattern is clear.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;- (DocumentMetaData*) createFolder:(DocumentMetaData*)folderInfo {
&amp;nbsp; &amp;nbsp; NSURL *folderURL = [folderInfo itemURL];
&amp;nbsp; &amp;nbsp; NSString *folderPath = [[folderURL path] stringByReplacingPercentEscapesUsingEncoding:UTF8Encoding];
&amp;nbsp; &amp;nbsp; DBUserClient *client = [self getDropboxClient];
&amp;nbsp;
&amp;nbsp; &amp;nbsp; [[client.filesRoutes createFolder:folderPath] setResponseBlock:^(DBFILESFolderMetadata *result, DBFILESCreateFolderError *routeError, DBRequestError *networkError) {
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (result) {
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ([delegate respondsToSelector:@selector(checkFolderCreated)]) {
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [delegate checkFolderCreated:YES];
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } else {
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LALog(@"%@\n%@\n", routeError, networkError);
}
}];
&amp;nbsp;
&amp;nbsp; &amp;nbsp;&amp;nbsp;//Wait-loop for create folder request with the given timeout
&amp;nbsp; &amp;nbsp; NSDate* giveUpDate = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_CREATE_FOLDER_IN_SECS];
&amp;nbsp; &amp;nbsp; while ( (self.currentRequestStatus == REQ_PROCESSING) &amp;amp;&amp;amp;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [giveUpDate timeIntervalSinceNow] &amp;gt; 0) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Keep looping.. Run the current run for a millisec for the Network and UI async events to be taken care of
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NSDate *stopDate = [NSDate dateWithTimeIntervalSinceNow:0.001];
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:stopDate];
&amp;nbsp; &amp;nbsp; }
&amp;nbsp;
Delegate Class:
&amp;nbsp;
- (void) checkFolderCreated:(BOOL)success withInfo:(NSDictionary *)infoPassedIn {
DocumentController *docController = (DocumentController*)[infoPassedIn objectForKey:@"DocumentController"];
&amp;nbsp; &amp;nbsp; &amp;nbsp;if (docController == nil)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;
&amp;nbsp;
…
&amp;nbsp;
[docController createFolder:docMetaData];
&amp;nbsp;
…
&amp;nbsp;
// some condition to pop out.
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here the first call to createFolder successfully has its response block called. &amp;nbsp;All additional calls execute the createFolder method (the folder is created) but the response block is not called.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The while loop is used to make the call synchronous in this case. &amp;nbsp;This may be interfering with the response block being called back but not sure. &amp;nbsp;Any ideas?&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jun 2017 18:01:23 GMT</pubDate>
    <dc:creator>rayleyendecker</dc:creator>
    <dc:date>2017-06-13T18:01:23Z</dc:date>
    <item>
      <title>DBRpcTask response block not called.</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/DBRpcTask-response-block-not-called/m-p/225446#M12235</link>
      <description>&lt;P&gt;I have a method that calls [&lt;SPAN&gt;client.&lt;/SPAN&gt;&lt;SPAN&gt;filesRoutes&lt;/SPAN&gt; &lt;SPAN&gt;createFolder&lt;/SPAN&gt;&lt;SPAN&gt;:folderPath]. In its&amp;nbsp;response block a call is made to &lt;/SPAN&gt;&lt;SPAN&gt;[client.&lt;/SPAN&gt;&lt;SPAN&gt;filesRoutes&lt;/SPAN&gt; &lt;SPAN&gt;search&lt;/SPAN&gt;&lt;SPAN&gt;:parentPath &lt;/SPAN&gt;&lt;SPAN&gt;query&lt;/SPAN&gt;&lt;SPAN&gt;:filename]. In its&amp;nbsp;response block another call is made to&amp;nbsp;[client.filesRoutes createFolder:folderPath] (checking for another folder) and so forth recuresively until everything gets unwound. &amp;nbsp;The first call works (response block is called) but the second (recursive) call does not result in its response bock&amp;nbsp;being&amp;nbsp;called. For example, the&amp;nbsp; [client.filesRoutes createFolder:folderPath] call created the folder but the response block is never called. &amp;nbsp;I am updating previously written code that worked fine when DBRestClient callbacks were used. &amp;nbsp;Not sure if this has something to do with calling Dropbox methods from within a&amp;nbsp;response block that has a response block itself.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:21:41 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/DBRpcTask-response-block-not-called/m-p/225446#M12235</guid>
      <dc:creator>rayleyendecker</dc:creator>
      <dc:date>2019-05-29T09:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: DBRpcTask response block not called.</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/DBRpcTask-response-block-not-called/m-p/225456#M12239</link>
      <description>Can you share the code that reproduces this, so we can make sure we understand the issue? Thanks in advance!</description>
      <pubDate>Mon, 12 Jun 2017 21:19:06 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/DBRpcTask-response-block-not-called/m-p/225456#M12239</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-06-12T21:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: DBRpcTask response block not called.</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/DBRpcTask-response-block-not-called/m-p/225490#M12246</link>
      <description>&lt;P&gt;Here is the code. &amp;nbsp;I tried to make it as minimal as possible but I think the pattern is clear.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;- (DocumentMetaData*) createFolder:(DocumentMetaData*)folderInfo {
&amp;nbsp; &amp;nbsp; NSURL *folderURL = [folderInfo itemURL];
&amp;nbsp; &amp;nbsp; NSString *folderPath = [[folderURL path] stringByReplacingPercentEscapesUsingEncoding:UTF8Encoding];
&amp;nbsp; &amp;nbsp; DBUserClient *client = [self getDropboxClient];
&amp;nbsp;
&amp;nbsp; &amp;nbsp; [[client.filesRoutes createFolder:folderPath] setResponseBlock:^(DBFILESFolderMetadata *result, DBFILESCreateFolderError *routeError, DBRequestError *networkError) {
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (result) {
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ([delegate respondsToSelector:@selector(checkFolderCreated)]) {
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [delegate checkFolderCreated:YES];
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } else {
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LALog(@"%@\n%@\n", routeError, networkError);
}
}];
&amp;nbsp;
&amp;nbsp; &amp;nbsp;&amp;nbsp;//Wait-loop for create folder request with the given timeout
&amp;nbsp; &amp;nbsp; NSDate* giveUpDate = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_CREATE_FOLDER_IN_SECS];
&amp;nbsp; &amp;nbsp; while ( (self.currentRequestStatus == REQ_PROCESSING) &amp;amp;&amp;amp;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [giveUpDate timeIntervalSinceNow] &amp;gt; 0) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Keep looping.. Run the current run for a millisec for the Network and UI async events to be taken care of
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NSDate *stopDate = [NSDate dateWithTimeIntervalSinceNow:0.001];
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:stopDate];
&amp;nbsp; &amp;nbsp; }
&amp;nbsp;
Delegate Class:
&amp;nbsp;
- (void) checkFolderCreated:(BOOL)success withInfo:(NSDictionary *)infoPassedIn {
DocumentController *docController = (DocumentController*)[infoPassedIn objectForKey:@"DocumentController"];
&amp;nbsp; &amp;nbsp; &amp;nbsp;if (docController == nil)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;
&amp;nbsp;
…
&amp;nbsp;
[docController createFolder:docMetaData];
&amp;nbsp;
…
&amp;nbsp;
// some condition to pop out.
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here the first call to createFolder successfully has its response block called. &amp;nbsp;All additional calls execute the createFolder method (the folder is created) but the response block is not called.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The while loop is used to make the call synchronous in this case. &amp;nbsp;This may be interfering with the response block being called back but not sure. &amp;nbsp;Any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 18:01:23 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/DBRpcTask-response-block-not-called/m-p/225490#M12246</guid>
      <dc:creator>rayleyendecker</dc:creator>
      <dc:date>2017-06-13T18:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: DBRpcTask response block not called.</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/DBRpcTask-response-block-not-called/m-p/225786#M12284</link>
      <description>(Apologies for the delay. It looks like there was an issue with the form, and your post wasn't showing up before.)&lt;BR /&gt;&lt;BR /&gt;Yes, I think that while loop might cause this. The response block runs asynchonrously, and on the main thread:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://github.com/dropbox/dropbox-sdk-obj-c#specify-api-call-response-queue" target="_blank"&gt;https://github.com/dropbox/dropbox-sdk-obj-c#specify-api-call-response-queue&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If I understand correctly, it sounds like you're blocking the main thread, so the response block may not get a chance to run.&lt;BR /&gt;&lt;BR /&gt;I recommend refactoring that to eliminate that, or use another queue or sempahores, or whatever makes sense for your app.&lt;BR /&gt;&lt;BR /&gt;(Also, one shortcut on the API side of things: if you're creating folders to contain files you'll later be uploading, you can actually skip the folder creation step entirely. When uploading files via the API, any parent folders in the destination path that don't already exist will be automatically created.)</description>
      <pubDate>Wed, 14 Jun 2017 19:19:25 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/DBRpcTask-response-block-not-called/m-p/225786#M12284</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-06-14T19:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: DBRpcTask response block not called.</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/DBRpcTask-response-block-not-called/m-p/225925#M12302</link>
      <description>&lt;P&gt;You are correct. &amp;nbsp;It was indeed a result of using the while loop to block and wait. Since the response block was running on the main thread along with my block and wait code my&amp;nbsp;repsonse block would not run until the my wait loop timed out. I fixed it by adding a queueu to each call so the response block runs in a seperate thread. &amp;nbsp;It all works now. &amp;nbsp;Thank you so much for your reply. &amp;nbsp;Have a greate day!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Ray&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 17:23:38 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/DBRpcTask-response-block-not-called/m-p/225925#M12302</guid>
      <dc:creator>rayleyendecker</dc:creator>
      <dc:date>2017-06-15T17:23:38Z</dc:date>
    </item>
  </channel>
</rss>

