Why is NSMetadataQueryDidUpdateNotification being called several times in quick succession?

后端 未结 1 562
迷失自我
迷失自我 2021-01-15 16:37

In order to monitor file changes in my iCloud container, I\'ve registered for

[[NSNotificationCenter defaultCenter] addObserver:self
                                


        
相关标签:
1条回答
  • 2021-01-15 17:39

    NSMetadataQueryDidUpdateNotification issues each time when some of attributes of any NSMetadataItem in NSMetadataQuery results update. It includes the the partial upload or download progress. So it is wrong to try to open UIDocument instance during this notification handling.

    Instead you could determine the moment when the document did download by observing the attribute values of NSMetadataItem and then queue it to be opened.

    Do not forget to handle NSMetadataQueryDidFinishGatheringNotification too. It is posted when the receiver has finished with the initial result - gathering phase of the query

    0 讨论(0)
提交回复
热议问题