I'm trying to update the iCloud data handling in our app, and I'm running into an issue with a particular file on one particular device. This file never downloads & I haven't been able to pinpoint what's off about it.
Right now we just have 2 iCloud accounts & a handful of devices, so I haven't been able to narrow it down yet, but in most cases, all the cloud files download as expected.
However, whether or not the file eventually downloads, the NSURLUbiquitousItemDownloadRequestedKey key seems to be completely useless.
For the following code:
NSError *error = nil;
BOOL success = [[NSFileManager defaultManager] startDownloadingUbiquitousItemAtURL:self.fileURL error:&error];
if (!success) {
NSLog(@"error downloading %@ : %@", self.fileURL, error);
} else {
NSDictionary *resourceValues = [self.fileURL resourceValuesForKeys:@[NSURLUbiquitousItemDownloadRequestedKey, NSURLUbiquitousItemIsDownloadingKey, NSURLUbiquitousItemDownloadingErrorKey, NSURLUbiquitousItemDownloadingStatusKey] error:&error];
if (!error) {
NSString *downloadStatus = resourceValues[NSURLUbiquitousItemDownloadingStatusKey];
bool downloadRequested = [resourceValues[NSURLUbiquitousItemDownloadRequestedKey] boolValue];
NSLog(@"download requested: %d", downloadRequested);
}
// ...
}
downloadRequested is always false, regardless of whether or not the cloud file eventually downloads.
I have 2 questions:
- is there a way to actually check if a download has been requested for a file?
- what could be preventing this file from downloading?
-startDownloadingUbiquitousItemAtURL:error:doesn't report an error,NSURLUbiquitousItemDownloadingErrorKeyis alwaysnil, and no error is reported in theNSMetadataQueryobserver.