Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Robert S.138
10 years agoHelpful | Level 7
Threads, tasks, and the Objective-C SDK
Having completed an Android version of my app, I was hoping that the Objective-C version for iOS would be similar. But looking at the DBRoulette example, there seems to be a big difference regarding...
Robert S.138
10 years agoHelpful | Level 7
I have been studying these API calls, and even with a custom queue, I don't see how to do what I want. First of all, here is the pseudo-code for what I have implemented in Android (omitting all error-handling), and what I want to do in iOS. It downloads all the files in Dropbox and runs in a single background thread - not the UI thread. I have also omitted all interactions with the main UI thread:
Code for thread:
processWithRecursion("); //..start with the root of Dropbox
end of execution of thread.
And here is the recursively-called function, processWithRecursion():
processWithRecursion( currentDirectory )
{
form list of currentDirectory
for each element in that list, do:
{
if(element is a directory)
{
create local destination directory of that name
processWithRecursion(currentDirectory + subdirectory name);
}
else //..element is a file
{
create destination file and download from Dropbox to that file
}
}
}
As you can see, the recursive call nicely steps through all the files, including any nested subdirectories. The call stack performs the function of keeping track of where we are in the search for files. This could be performed by an elaborate state machine, but then I would have to create a separate push-down stack data structure to traverse the directory tree.
This process is best implemented with API functions that block. But it seems the API functions available to me do not block, so there is no easy way to execute a series of these API calls by simply writing them one after another in code. For example, I would need to call listFolder:searchPath to get the list of files in one directory, and then for each of the items returned in the list I would need to call downloadData:filePath to actually do the download. But both of these API calls are implemented as non-blocking calls that return immediately, leaving the completion block to handle the completion of the action. So I could not write listFolder:searchPath followed immediately by downloadData:filePath, because the downloadData: method would start executing before the searchPath: method was completed. In fact, I couldn't even form a filePath parameter for downloadData: without examining the completion of searchPath:
That was just for downloading one file. When you throw in the need for traversing the entire directory tree with recursion, all without any UI input, I don't see a neat way of doing this.
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!