I have an App in the AppStore since 2013 and it always worked flawlessly. It creates and syncs files on iCloud.
Since iOS14 startDownloadingUbiquitousItemAtURL only downloads a fraction of the existing files. If I start the App in the simulator and iOS14 (and of course on the real devices as well). If I start the App in a simulator using iOS12 or 13 it works as expected.
I don't find anything on the web regarding possible changes in the startDownloadingUbiquitousItemAtURL method.
Here's the code in question:
...
BOOL tt = [[NSFileManager defaultManager] startDownloadingUbiquitousItemAtURL:cloudFileUrl error:&error] ;
if (error != nil)
{
NSLog(@"ERROR Loading %@", cloudFileUrl) ;
}
...
tt is true and error is nil, so it seems the sync process has started correctly
However, If I try to access the files with
NSArray *dirContent = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:cloudFileUrl includingPropertiesForKeys:[[NSArray alloc] initWithObjects:NSURLNameKey, nil] options:NSDirectoryEnumerationSkipsHiddenFiles error:&error];
The the array dirContent contains only 3 or 4 elements, even though the folder contains 10 files.
Any idea what the problem could be? I have opened a bug with Apple as well.
Ok, the solution ist that this call does not read some files when they are binary. Alleged text files were found.
NSArray *dirContent = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:cloudFileUrl includingPropertiesForKeys:[[NSArray alloc] initWithObjects:NSURLNameKey, nil] options:NSDirectoryEnumerationSkipsHiddenFiles error:&error];
I've replaced the call with this
NSArray *dirContent = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:cloudFileUrl includingPropertiesForKeys:[[NSArray alloc] initWithObjects:NSURLNameKey, nil] options:0 error:&error];
and now it works again.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.