相关疑难解决方法(0)

下载iCloud文件的方法?很混乱?

我在我的应用程序中有基本的iCloud支持(同步更改,无处不在等),但到目前为止一个重要的遗漏是缺乏对云中存在(或有变化)的文件的"下载"支持,但不是与当前磁盘上的内容同步.

我根据一些Apple提供的代码,在我的应用程序中添加了以下方法,并进行了一些调整:

下载方式:

- (BOOL)downloadFileIfNotAvailable:(NSURL*)file {
    NSNumber*  isIniCloud = nil;

    if ([file getResourceValue:&isIniCloud forKey:NSURLIsUbiquitousItemKey error:nil]) {
        // If the item is in iCloud, see if it is downloaded.
        if ([isIniCloud boolValue]) {
            NSNumber*  isDownloaded = nil;
            if ([file getResourceValue:&isDownloaded forKey:NSURLUbiquitousItemIsDownloadedKey error:nil]) {
                if ([isDownloaded boolValue])
                    return YES;

                // Download the file.
                NSFileManager*  fm = [NSFileManager defaultManager];
                NSError *downloadError = nil;
                [fm startDownloadingUbiquitousItemAtURL:file error:&downloadError];
                if (downloadError) {
                    NSLog(@"Error occurred starting download: %@", downloadError);
                }
                return NO;
            }
        }
    }

    // Return …
Run Code Online (Sandbox Code Playgroud)

macos objective-c ios icloud

13
推荐指数
3
解决办法
9446
查看次数

UIManagedDocument示例/教程

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

我对以下内容感到困惑:

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

iphone core-data objective-c icloud uimanageddocument

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

标签 统计

icloud ×2

objective-c ×2

core-data ×1

ios ×1

iphone ×1

macos ×1

uimanageddocument ×1