繁体   English   中英

NSFileManager startDownloadingUbiquitousItemAtURL 在 iOS14 上无法正常工作

[英]NSFileManager startDownloadingUbiquitousItemAtURL not working correctly on 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 为真且错误为零,因此同步过程似乎已正确启动

但是,如果我尝试访问文件

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

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

知道可能是什么问题吗? 我也用苹果打开了一个错误。

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

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];

现在它又可以工作了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM