Changes

Jump to: navigation, search

Using iCloud Storage in an iOS 9 Application

16 bytes removed, 20:34, 1 February 2016
m
Text replacement - "<google>BUY_IOS9</google>" to "<htmlet>ios9</htmlet>"
<googlehtmlet>BUY_IOS9ios9</googlehtmlet>
ubiquityURL = filemgr.URLForUbiquityContainerIdentifier(nil)
</pre>
<googlehtmlet>BUY_IOS9ios9</googlehtmlet>
The app will only be able to obtain the ubiquityURL if the user has configured a valid Apple ID within the iCloud page of the iOS Settings app. Some defensive code needs to be added, therefore, to notify the user and return from the viewDidLoad method if a valid ubiquityURL could not be obtained. For the purposes of testing in this example we will simply output a message to the console before returning:
When the meta data query was triggered in the viewDidLoad method to search for documents in the Documents directory of the application’s iCloud storage area, an observer was configured to call a method named metadataQueryDidFinishGathering when the initial search completed. The next logical step is to implement this method. The first task of the method is to identify the query object that caused this method to be called. This object must then be used to disable any further query updates (at this stage the document either exists or doesn’t exist so there is nothing to be gained by receiving additional updates) and stop the search. It is also necessary to remove the observer that triggered the method call. Combined, these requirements result in the following code:
<googlehtmlet>BUY_IOS9ios9</googlehtmlet>
<pre>
let query: NSMetadataQuery = notification.object as! NSMetadataQuery
<googlehtmlet>BUY_IOS9ios9</googlehtmlet>

Navigation menu