为什么不开始DownloadDownloadUbiquitousItemAtURL:fileURL:开始下载该项目?

编程入门 行业动态 更新时间:2024-10-25 20:24:13
本文介绍了为什么不开始DownloadDownloadUbiquitousItemAtURL:fileURL:开始下载该项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用NSMetadataQuery在iCloud中检查文件.在NSMetadataQueryDidFinishGatheringNotification处理程序内部,如果未下载项目或未下载项目,则开始使用startDownloadingUbiquitousItemAtURL:fileURL:下载该项目-但是最近,在两台设备上使用该应用程序后,文档似乎被卡住了. startDownloadingUbiquitousItemAtURL:fileURL:不再开始下载.

I'm using an NSMetadataQuery to check for files in iCloud. Inside the NSMetadataQueryDidFinishGatheringNotification handler, if the item isn't downloaded or downloading I start downloading it using startDownloadingUbiquitousItemAtURL:fileURL: - but recently, after using the app on two devices, the documents seem to have got stuck; startDownloadingUbiquitousItemAtURL:fileURL: doesn't kick off a download any more.

下面是代码的缩写形式:

Here's an abbreviated form of the code:

for (NSMetadataItem * result in query.results) { NSURL *fileURL = [result valueForAttribute:NSMetadataItemURLKey]; // snipped: checks that the item isn't hidden or already downloaded if (![fileURL getResourceValue:&isDownloading forKey:NSURLUbiquitousItemIsDownloadingKey error:&error] || !isDownloading) { NSLog(@"Error %@ getting downloading state for item at %@", error, fileURL); continue; } if ([isDownloading boolValue]) { if (![fileURL getResourceValue:&downloadPercent forKey:NSURLUbiquitousItemPercentDownloadedKey error:&error] || !downloadPercent) { NSLog(@"Error %@ getting downloaded progress for item at %@", error, fileURL); continue; } NSLog(@"Item at %@ has is %@%% downloaded", fileURL, downloadPercent); } else { NSLog(@"Starting to download item at %@", fileURL); if ([[NSFileManager defaultManager] startDownloadingUbiquitousItemAtURL:fileURL error:&error]) { isDownloading = nil; if ([fileURL getResourceValue:&isDownloading forKey:NSURLUbiquitousItemIsDownloadingKey error:&error] && isDownloading) { if ([isDownloading boolValue]) { NSLog(@"After starting to download, item at %@ is downloading.", fileURL); } else { NSLog(@"After starting to download, item at %@ is still not downloading!", fileURL); } } else { NSLog(@"Error %@ getting downloading state again for item at %@", error, fileURL); } } else { NSLog(@"Error %@ starting to download item at %@", error, fileURL); } } }

我看到的是:

Starting to download item at XXXXXXXX After starting to download, item at XXXXXXXX is still not downloading! Starting to download item at YYYYYYYY After starting to download, item at YYYYYYYY is still not downloading! Starting to download item at ZZZZZZZZ After starting to download, item at ZZZZZZZZ is still not downloading!

为什么不开始DownloadDownloadUbiquitousItemAtURL:fileURL:开始下载该项目?如果是由于某些冲突,我该如何检测到该冲突?

Why isn't startDownloadingUbiquitousItemAtURL:fileURL: starting a download of the item? If it's due to some conflict, how do I detect that conflict?

更新:我已经看过设备控制台了,我看到了:

UPDATE: I've had a look at the device console, and I see this:

MyApp[NNNN] <Warning>: Starting to download item at XXXXXXXX librariand[MMMM] <Error>: unable to download XXXXXXXX (0x8000000000000000) MyApp[NNNN] <Warning>After starting to download, item at XXXXXXXX is still not downloading! MyApp[NNNN] <Warning>Starting to download item at YYYYYYYY librariand[MMMM] <Error>: unable to download YYYYYYYY (0x8000000000000000) MyApp[NNNN] <Warning>After starting to download, item at YYYYYYYY is still not downloading! MyApp[NNNN] <Warning>Starting to download item at ZZZZZZZZ librariand[MMMM] <Error>: unable to download ZZZZZZZZ (0x8000000000000000) MyApp[NNNN] <Warning>After starting to download, item at ZZZZZZZZ is still not downloading!

因此,看起来至少守护程序被告知要下载文件,即使不能.有关于馆员错误的任何文档吗?

So it looks like at least the daemon is being told to download the file, even though it can't. Is there any documentation on librariand errors?

推荐答案

仔细研究NSMetadataQuery结果中的NSMetadataItem.当您遍历查询请求的结果时,可以获取以下属性的值:

Take a closer look at NSMetadataItem in your NSMetadataQuery results. When you iterating through the results of your query request you can get values for the following attributes instead:

NSString * const NSMetadataUbiquitousItemIsDownloadedKey; NSString * const NSMetadataUbiquitousItemIsDownloadingKey; NSString * const NSMetadataUbiquitousItemIsUploadedKey; NSString * const NSMetadataUbiquitousItemIsUploadingKey; NSString * const NSMetadataUbiquitousItemPercentDownloadedKey; NSString * const NSMetadataUbiquitousItemPercentUploadedKey;

更多推荐

为什么不开始DownloadDownloadUbiquitousItemAtURL:fileURL:开始下载该项目?

本文发布于:2023-11-26 17:42:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634548.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:该项目   DownloadDownloadUbiquitousItemAtURL   fileURL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!