相关疑难解决方法(0)

如何告诉iOS从iCloud Drive下载文件并获得进度反馈

我正在使用UIDocumentPicker来选择文件,但如果它很大,则可能需要一段时间才能打开,这对用户来说并不是特别好的体验.

我看过Apple的iCloud编程指南,我似乎无法弄清楚如何实际下载文件并获得一些进度反馈,文档太模糊了.我知道我应该对NSMetadataItems做一些事情,但实际上没有太多解释如何获得并使用它.

有人可以向我解释一下吗?

PS可以用比我更高的代表用UIDocumentPicker和iCloudDrive标记这篇文章?

cocoa objective-c icloud ios8

7
推荐指数
1
解决办法
4540
查看次数

UIManagedDocument示例/教程

我一直试图创建一个简单的UIManagedDocument库样式应用程序(保存到iCloud的单独文档)非常失败.

我对以下内容感到困惑:

难道我的子类UIManagedDocument,并成立了persistentStoreCoordinator,ManagedObjectModelManagedObjectContext这个子类中,或者这些应该是内部配置的AppDelegate(如果是的话,我怎么去刷新persistentStoreCoordinator看新的文件-看来,一旦已经读了persistentStore这我不能让它读取新的持久存储)?

iphone core-data objective-c icloud uimanageddocument

6
推荐指数
1
解决办法
9305
查看次数

icloud不会更新下载进程

通常,我的代码可以从iCloud下载文件.但有时下载过程不会更新.

以下是一些代码剪辑:

开始下载:

            NSFileManager*  fm = [NSFileManager defaultManager];
        if (![fm startDownloadingUbiquitousItemAtURL:file error:nil]) {
            return NO;
        }

        /////////////////////////
        id query = [[icloudClass alloc] init];
        _query = query;

        [query setSearchScopes:[NSArray arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope]];

        NSArray *listItems = [[file path] componentsSeparatedByString:@"/"];

        NSPredicate *pred = [NSPredicate predicateWithFormat: @"%K == %@", NSMetadataItemFSNameKey, [listItems objectAtIndex:[listItems count] -1] ];
        NSLog(@"filename = %@", [listItems objectAtIndex:[listItems count] -1]);
        [query setPredicate:pred];

       [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDownloading:) name:NSMetadataQueryDidUpdateNotification object:query];

        [query startQuery];
Run Code Online (Sandbox Code Playgroud)

更新下载:

    -(void)updateDownloading:(NSNotification *)notification {
    id query = [notification object];


    if ([query resultCount] /*>=*/ == …
Run Code Online (Sandbox Code Playgroud)

ios5 icloud icloud-api

5
推荐指数
0
解决办法
2453
查看次数

是 iCloud 还是我的代码?

我正在使用这个问题的稍微更新的代码:下载 iCloud 文件的方法?非常混淆?

这是代码的摘录:

private func downloadUbiquitiousItem(atURL url: URL) -> Void {
        do {
            try FileManager.default.startDownloadingUbiquitousItem(at: url)
            do {
                let attributes = try url.resourceValues(forKeys: [URLResourceKey.ubiquitousItemDownloadingStatusKey])
                if let status: URLUbiquitousItemDownloadingStatus = attributes.allValues[URLResourceKey.ubiquitousItemDownloadingStatusKey] as? URLUbiquitousItemDownloadingStatus {
                    if status == URLUbiquitousItemDownloadingStatus.current {
                        self.processDocument(withURL: url)
                        return
                    } else if status == URLUbiquitousItemDownloadingStatus.downloaded {
                        self.processDocument(withURL: url)
                        return
                    } else if status == URLUbiquitousItemDownloadingStatus.notDownloaded {
                        do {
                            //will go just fine, if it is unnecessary to download again
                            try FileManager.default.startDownloadingUbiquitousItem(at: url)
                        } catch {
                            return …
Run Code Online (Sandbox Code Playgroud)

icloud swift icloud-documents

5
推荐指数
1
解决办法
1348
查看次数