I used, as described in Apple Docs NSMetadataQuery, to find the iCloud file. I have only one file, and I know its name. My problem is that sometimes this file does not exist (I think because it is not loaded yet) and NSMetadataQuery cannot find it.
Ever tried to force download using NSFileManager startDownloadingUbiquitousItemAtURL:error:, and it returns me an error. (Read EDIT)
My solution is that I created the file for the first time, then I think it exists and I open it with a UIDocument. But it cannot exist or it can be the first time the user opens the application. I can not be sure of this. My first question is: if UIDocument opens the file, it means that it found the file somewhere. How can it use a file if it DOES NOT EXIST?
And then, the second question: If I am an application that needs to manage multiple files or files with an unknown name. How can I find them if NSMetadataQuery does not work.
EDIT:
if you startDownloadingUbiquitousItemAtURLshould use to start downloading a file, how do you know when the file has finished downloading (possibly with a notification)? But, more importantly: how to upload a file if it always says (original names removed)?
Error Domain=NSPOSIXErrorDomain Code=2 "The operation couldn’t be completed.
No such file or directory" UserInfo=0x166cb0 {
NSDescription=Unable to get real path for Path
'/private/var/mobile/Library/Mobile Documents/teamid~com~team~app/Documents/file.extension'
}