1

方法在哪里startDownloadingUbiquitousItemAtURL:error保存下载的文件在本地?
和给定的一样URL吗?

4

1 回答 1

3

是的,它的网址相同

从 iCloud 下载到设备之前的文件是一种占位符。

您可以使用密钥检查 URL 的状态NSURLUbiquitousItemIsDownloadedKey

NSURL *foo = file://cloud/container/reference/tofile;

NSNumber *isDownloadedValue = NULL;

BOOL success = [foo getResourceValue:&isDownloadedValue forKey: NSURLUbiquitousItemIsDownloadedKey error:NULL];

if (success && ![isDownloadedValue boolValue]) {
    [[NSFileManager defaultManager] startDownloadingUbiquitousItemAtURL:foo error:NULL];
}

该片段中没有您想要在生产代码中执行的错误处理。

于 2013-08-20T10:33:52.507 回答