0

我有以下代码:

// Main thread
NotificationCenter.default.addObserver( self,
    selector:#selector(queryDidFinish),
    name:NSNotification.Name.NSMetadataQueryDidFinishGathering, object:nil)

NotificationCenter.default.addObserver( self,
    selector:#selector(queryDidUpdate),
    name:NSNotification.Name.NSMetadataQueryDidUpdate, object:nil)

并且:

private var query = NSMetadataQuery() // Class level

func queryCloud()
{
    // Called on main thread
    query.searchScopes = [NSMetadataQueryUbiquitousDocumentsScope]
    query.predicate = NSPredicate(format: "(%K like '*.jpg')",
                                    NSMetadataItemFSNameKey) 
    queryHot.start()
}

@objc func queryDidFinish(notification: NSNotification)
{
    print("This gets called once on main thread")
    print("and the query can be read")
}

@objc func queryDidUpdate(notification: NSNotification)
{
    print("This does not get called")
}

因此,上述“曾经工作”,跨两个设备。现在,两个设备都没有得到 queryDidUpdate() 调用。我试过删除应用程序,打开和关闭云权限,登录和退出 iCloud,重新启动设备。两个设备都可以读取它们的“冻结”云,但不会传播任何数据,也不会传递实时阶段通知。几天来,我确实在两台设备之间进行了一些繁重的测试(传输数百 MB 的图片)。而现在,一切都停止了。

每个设备的云令牌完全不同,但都是稳定的。使用 UIDocument 存储到云端。

我错过了什么吗?我需要在 iCloud 中重置什么吗?有没有我可以在某处检查的状态?

我不想更改应用程序包 ID 来摆脱困境……我想找到根本问题。感谢您的任何提示!

4

1 回答 1

0

The code is okay, but the iCloud on the device was in a state. Ultimately, I turned off and on "iCloud Drive" (which is different than just signing on to iCloud). After putting back settings for the app, everything started to work.

于 2018-10-21T20:04:12.110 回答