ios - 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 为真且错误为 nil,因此似乎同步过程已正确启动
但是,如果我尝试使用
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];
现在它又可以工作了。
推荐阅读
- javascript - 我可以使用 chrome 扩展程序注入 intercom.io 吗?
- ios - 如何在滚动视图中制作一组按钮?
- javascript - 未为 plotLines highcharts 呈现标签
- go - 将外部错误映射到 golang 中的域错误
- c# - 使用表达式树构建动态查询
- r - 使用testthat时的R源文件位置问题
- laravel-nova - 未找到列:1054:使用 nova-repeatable-fields 时 MySQL 中“字段列表”中的未知列“员工”
- google-api - Google 登录用户更改了侦听器
- javascript - 如何在页面加载期间从函数更新对象值
- mysql - 根据时间戳删除超过 24 小时或 1 天的记录