【问题标题】:UIDocument update in iCloud is not notified未通知 iCloud 中的 UIDocument 更新
【发布时间】:2015-02-25 15:01:18
【问题描述】:

我已经实现了单个文档的 iCloud 同步。 当应用程序启动时,支架始终是真实的,但在其他设备上并行进行的更改永远不会在应用程序运行时传播(我见过一次,不确定我是否没有梦想过那个时间)。

我已经实现了

                _metadataQuery = [[NSMetadataQuery alloc] init];
                _metadataQuery.searchScopes = @[NSMetadataQueryUbiquitousDataScope];
                _metadataQuery.predicate = [NSPredicate predicateWithFormat:@"%K like %@", NSMetadataItemFSNameKey, fileName];
                [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(metadataQueryDidUpdate:) name:NSMetadataQueryDidUpdateNotification object:_metadataQuery];
                [_metadataQuery startQuery];

它被调用,例如当我保存文档时(所以它主要工作)。

还有

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(documentStateChanged:) name:UIDocumentStateChangedNotification object:self];

用于子类 UIDocument。

在 Xcode 中,我在另一台设备上进行更改后看到我的应用程序的一些下载活动...(但它从不显示任何上传活动,即使我在另一台设备上看到数据正在被实现)

但是没有调用相应的方法。 如果我冷启动应用程序 - 一切都很好(我得到“新”数据)。

有什么想法可能会丢失吗? 注意:可能有某种相关性 - 我在阅读后立即关闭文档,因此文档通常处于“关闭”状态...

【问题讨论】:

    标签: ios objective-c icloud


    【解决方案1】:

    看来我重用了错误的例子,不得不使用

    _metadataQuery.searchScopes = @[NSMetadataQueryUbiquitous文档Scope];

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-12
      • 2020-04-15
      • 1970-01-01
      • 2018-03-13
      • 1970-01-01
      • 1970-01-01
      • 2018-03-30
      • 1970-01-01
      相关资源
      最近更新 更多