I am having trouble understanding how updates work with an NSMetadataQuery.
I am trying to determine whether a file has finished downloading from iCloud. My initial query tells me clearly enough the the file is not downloaded and I can start the download, but I want to put up a progress bar if it is going to take any time to download the file. I have invoked enableUpdates, but it doesn't seem to alter either the downloading/downloaded status or the percent downloaded even though I am fairly certain the file is downloading. (I get stuck in a while loop. If I quit and rerun the app, it sees the files as downloaded and skips the while loop.)
Do I have to start a new query to get updates? If so, what is the function of the enableUpdates and disableUpdates?
Is there some different way the initial query has to be invoked in order to get updates? I got this impression from something in the documentation but I couldn't find any details that seemed to explain how.
Very good sample code and explanation from Apple here:
https://developer.apple.com/library/ios/#documentation/DataManagement/Conceptual/DocumentBasedAppPGiOS/ManageDocumentLifeCycle/ManageDocumentLifeCycle.html#//apple_ref/doc/uid/TP40011149-CH4-SW6
Basically you just leave the query running all the time (except when you go into the background). You get a notification whenever there's a change in the situation, and you maintain your document lists accordingly. A document that has not yet been downloaded from the cloud is initially a placeholder; as you can see from the next section, "Downloading Document Files from iCloud", the download won't happen until you ask it to with
startDownloadingUbiquitousItemAtURL:error:
(or try to read the document withopenWithCompletionHander:
).