Q:

google drive sdk and the handling of folders

I'm considering adding support for Google Drive in an iOS application I've written.  That's not my issue - there is plenty of decent documentation on how to do that.
My issue is that the data source for this application is a folder. This folder could conceivably contain dozens of (nested) child folders and hundreds of files sprinkled throughout.  
When I scour the documentation for Google Drive, there's plenty of information on the treatment of individual files; there is however very little information on the treatment of folders (other than folders appear to have a unique MIME type).
So assuming I can run a query to identify a GTLDriveFile that references a folder (data source) I'm interested in, I need to download the entire contents of that folder - hierarchical organization intact - to my application's sandbox.  BTW, this application is primarily for tablets (iPad).
How do I do that?
Thanks,

A:

The Google Drive model is internally a flat model with pointers to parents and children, any implementation that projects it into a traditional tree based model needs careful consideration. 
Since I don't work in iOS, I'll try to keep it general, referring to JAVA code snippets; it should be easy to translate it to any language (believe iOS has some king of 'C' flavor). 
So, every attempt to retrieve folders/files has to start with the Drive root, enumerating it's children. For instance, in new Google Drive API (GDAA) you'll use either.
DriveFolder.listChildren(gac).await()  
DriveFolder.queryChildren(gac, query).await();

where 'gac' is GoogleApiClient instance and 'query' comes from Query.Builder()... . 
As you keep going, you're getting metadata of objects, giving you full info about the object (mime, status, title, type,...), you handle duplicates (yes you can have multiple folders/files with the same name - but unique IDs). When you hit folder, start another iteration. In the process, you may cache the structure using folders' / files' unique RESOURCE IDs' (the string you see in http address of a file / folder). 
There are 2 different APIs in Java/Android world at the moment, the old RESTFul API and the new GDAA (and I don't know how it applies to iOS). And I have some code here, showing recursion down the tree (buildTree()), and code that handles duplicate file/folder names in (findFirst()). But unfortunately it is Java under GDAA flavor, so it may not be very useful to your case.
One more thing worth mentioning is, that you can 'list' or 'query' children of only one folder level (not it's subfolders), or you can query (but not list) all objects globally within your current scope (FILE scope only in GDAA, many scopes in RESTful).

