簡體   English   中英

沒有收到NSMetaDataQuery更新通知

[英]Not getting NSMetaDataQuery update Notification

我有以下代碼:

// 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,以免被卡住...我想找到潛在的問題。 感謝您的提示!

代碼還可以,但是設備上的iCloud處於狀態。 最終,我關閉並打開“ iCloud Drive”(這與僅登錄iCloud不同)。 放回應用程序的設置后,所有內容開始起作用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM