iCloud文档不可见 [英] iCloud Documents not visible

查看:214
本文介绍了iCloud文档不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用iCloud Documents来存储我的iOS应用程序中的XML文件。一切似乎都运行良好(我可以无错误地编写和读取文件),除了我的应用程序文件不会出现在icloud.com和developer.icloud.com以及iCloud Drive文件夹中的Windows PC上的iCloud Documents中。我在模拟器中运行应用程序,并在真实设备上使用TestFlight进行测试。我安装了最新版本的iCloud for Windows 4.0。该应用程序是在Xcode 6中创建的。

I am trying to use iCloud Documents to store XML files from my iOS App. Everything seems to be working fine (I can write and read files without errors) except my App's files do not show up in iCloud Documents neither in icloud.com nor in developer.icloud.com nor on my Windows PC in iCloud Drive folder. I was running the app in simulator and tested with TestFlight on a real device. I have the latest version of iCloud for Windows 4.0 installed. The App is created in Xcode 6.

有谁知道如何使文件出现在iCloud Documents中?

Does anyone know how to make the files appear in iCloud Documents?

我用来保存文件的代码:

The code I am using for the saving the file:

NSLog(@"Syncing with iCloud");
    NSURL *ubiq = [filemgr URLForUbiquityContainerIdentifier:nil];
    if (ubiq) {
        NSURL *ubiquitousPackage = [ubiq URLByAppendingPathComponent:@"Documents" isDirectory:YES];
        if ([filemgr fileExistsAtPath:[ubiquitousPackage path]] == NO)
            [filemgr createDirectoryAtURL:ubiquitousPackage
              withIntermediateDirectories:YES
                               attributes:nil
                                    error:nil];

        ubiquitousPackage = [ubiquitousPackage URLByAppendingPathComponent:@"data.pxa"];

        DataFile *file = [[DataFile alloc] initWithFileURL:ubiquitousPackage];
        file.xmlContent = doc.XMLString;
        [file saveToURL:[file fileURL] forSaveOperation:UIDocumentSaveForCreating | UIDocumentSaveForOverwriting completionHandler:^(BOOL success) {

            if (success) {
                NSLog(@"Synced with iCloud: %@", [ubiquitousPackage path]);

            } else {
                NSLog(@"Syncing with iCloud failed");
            }
        }];
    } else {
        NSLog(@"iCloud not available");
    }


推荐答案

我发现了什么问题是:
iCloud容器的Info.plist中的键与iCloud.com.example.MyApp格式略有不同。

I found out what the problem was: The key in Info.plist for the iCloud container was a bit different from the format "iCloud.com.example.MyApp".

这篇关于iCloud文档不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆