Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Two new metadata scopes, NSMetadataQueryUbiquitousDataScope and NSMetadataQueryUbiquitousDocumentsScope, point to the iCloud’s Data and Documents folders. You can add an ongoing query to monitor these folders, creating a callback whenever the folder contents change. This allows you to know when new items appear or disappear and update your file listings accordingly. Listing 18-1 offers a pair of methods that demonstrate how to use this technology to query and monitor the folder:
• The first method, startMonitoringUbiquitousDocumentsFolder, sets up a monitor for the Documents folder scope, listening for update notifications. When these occur, the method uses an informal delegate callback to update a client.
• The second method, stopMonitoringUbiquitousDocumentsFolder, cancels the notification observation, allowing your code to stop any ongoing monitoring.