Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone iCloud似乎只在启动时起作用_Iphone_Ipad_Icloud - Fatal编程技术网

Iphone iCloud似乎只在启动时起作用

Iphone iCloud似乎只在启动时起作用,iphone,ipad,icloud,Iphone,Ipad,Icloud,我正在尝试创建一个使用核心数据的iCloud应用程序。为此,我使用UIManagedDocument的单个实例。对于persistentStoreOptions,我为NSPersistentStoreUbiquitousContentNameKey设置了“Database.data”,为NSPersistentStoreUbiquitousContentURLKey设置了-iCloudURL-/CoreData\u日志。正如苹果公司建议的那样,我打开文档如下: if ([[NSFileManag

我正在尝试创建一个使用核心数据的iCloud应用程序。为此,我使用
UIManagedDocument
的单个实例。对于
persistentStoreOptions
,我为
NSPersistentStoreUbiquitousContentNameKey
设置了“Database.data”,为
NSPersistentStoreUbiquitousContentURLKey
设置了-iCloudURL-/CoreData\u日志。正如苹果公司建议的那样,我打开文档如下:

if ([[NSFileManager defaultManager] fileExistsAtPath:[urlOfDatabase path]])
{
    [_database openWithCompletionHandler:^(BOOL success) { ... }];
}
else
{
    [_database saveToURL:urlOfDatabase
        forSaveOperation:UIDocumentSaveForCreating
       completionHandler:^(BOOL success) { ... }];
}
另外,我注册了
NSPersistentStoreDidImportUbiquitousContentChangesNotification
s,并将通知中的上下文合并到该方法中

为了测试这个应用程序,我使用了iPad和iPhone。当我在一台设备上运行它,添加一些数据,然后在另一台设备上打开它时,会显示正确的数据。但是,如果我在两台设备上运行应用程序时添加数据,它要么不更新(我至少等了10分钟一次),要么几分钟后更新,但只会出现一大堆错误消息:“该项目未能下载。”

我是否错过了一些(希望是明显的)我的设置