NSFileManager startDownloadingUbiquitousItemAtURL在iOS14上无法正常工作

问题描述

自2013年以来,我在AppStore中有一个应用程序,并且始终运行良好。它在iCloud上创建并同步文件。

由于iOS14 startDownloadingUbiquitousItemAtURL仅下载了一部分现有文件。如果我在模拟器和iOS14中启动该应用程序(当然在真实设备上也是如此)。如果我在使用iOS12或13的模拟器中启动该应用程序,它将按预期运行。

在网络上,找不到关于startDownloadingUbiquitousItemAtURL方法中可能更改的任何内容。

这是有问题的代码:

...
BOOL tt =  [[NSFileManager defaultManager] startDownloadingUbiquitousItemAtURL:cloudFileUrl error:&error] ;

if (error != nil)
{
    NSLog(@"ERROR Loading %@",cloudFileUrl) ;
}
...

tt为true,错误为nil,因此看来同步过程已正确启动

但是,如果我尝试使用

来访问文件
NSArray *dirContent = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:cloudFileUrl includingPropertiesForKeys:[[NSArray alloc] initWithObjects:NSURLNameKey,nil] options:NSDirectoryEnumerationSkipsHiddenFiles error:&error];

数组dirContent仅包含3个或4个元素,即使该文件夹包含10个文件。

任何想法可能是什么问题?我也与Apple一起打开了一个错误。

解决方法

好的,解决方案是此调用在二进制文件中不读取某些文件。找到了所谓的文本文件。

NSArray *dirContent = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:cloudFileUrl includingPropertiesForKeys:[[NSArray alloc] initWithObjects:NSURLNameKey,nil] options:NSDirectoryEnumerationSkipsHiddenFiles error:&error];

我已将通话替换为

NSArray *dirContent = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:cloudFileUrl includingPropertiesForKeys:[[NSArray alloc] initWithObjects:NSURLNameKey,nil] options:0 error:&error];

现在又可以使用了。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...