Xcode 4 Cookbook by unknow
Author:unknow
Language: eng
Format: epub
Publisher: Packt Publishing
The following screenshot shows our snippet document existing within our application's container within iCloud:
Note
The previous screen can be accessed using the Settings application and then navigating to Settings | iCloud | Storage & Backup | Manage Storage.
How it works...
In this recipe, we learned how to build and create the user interface for our iCloudExample application to store and retrieve documents within iCloud. We then created the outlet properties for each of our buttons to have the ability of saving and loading the document when pressed. In our next step, we create a UIDocument subclass and declare an NSString property variable docContent that will be used to store the contents of our document when it gets created or modified. We then proceed to synthesize our document content property so that our class can access those objects associated with it. We then proceed to override the loadFromContents: method to read the data from the file into our UIDocument subclass. The most important parameter to note here is contents; this is an NSData object containing the actual data that was entered when you created or updated your document model.
The background queue NSFilePresenter calls this method whenever a read operation has completed. If the document was saved without entering any data, we assign a default value of empty string. We then proceed to override the contentsForType: method that is used when the background queue of the NSFilePresenter requests a snapshot of the contents of the UIDocument subclass. Here we check to ensure that the document contains contents, and if so, we convert our documents data to an NSData object, and return this as an NSData instance. Next, we declare our Snippet object that will be used to hold the document that gets created, as well as our NSMetadataQuery object that will be used to query and look up the document within our application's iCloud repository and access the relevant object properties of each file. In our next steps, we first check to ensure that we can access our application's iCloud repository, and then proceed to set the background color and font name and size for our docContents control, before finally calling the reload: method to pull the document from our iCloud repository.
We then proceed to register an observer object to enable us to periodically check for changes in document state using the UIDocumentStateChangedNotification notification object. Next, we declare our btnSave: method and set up an ubiq variable to point to our document container within our iCloud account. We then use the ubiquitousPackage class, and then append our filename to the location of the iCloud documents container. We then initialize our UIDocument class document with some default contents and then use the UIDocumentSaveForCreating property of our forSaveOperation method to create a brand new document.
For the btnLoad: method, we start by ensuring that we can connect it to the iCloud data store, and then set up and initialize our docQuery query predicate to look for our document using the predicate class method NSMetadataQueryUbiquitousDocumentScope and then set
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Personalized inhaled bacteriophage therapy for treatment of multidrug-resistant Pseudomonas aeruginosa in cystic fibrosis by unknow(178334)
CONSORT 2025 statement: updated guideline for reporting randomized trials by unknow(86865)
Critical evaluation of the ProfiLER-02 study design and outcomes by Vivek Subbiah & Razelle Kurzrock(86437)
Cardiac gene therapy makes a comeback by Oliver J. Müller & Susanne Hille & Anca Kliesow Remes(86227)
Whisky: Malt Whiskies of Scotland (Collins Little Books) by dominic roskrow(74442)
Unveiling the design rules for tunable emission in graphene quantum dots: A high-throughput TDDFT and machine learning perspective by Şener Özönder & Mustafa Coşkun Özdemir & Caner Ünlü(50895)
A yeast-based oral therapeutic delivers immune checkpoint inhibitors to reduce intestinal tumor burden by unknow(40265)
Covalent hitchhikers guide proteins to the nucleus by Alexander F. Russell & Madeline F. Currie & Champak Chatterjee(40217)
Meet the Authors: Christopher R. Mansfield and Emily R. Derbyshire by Christopher R. Mansfield & Emily R. Derbyshire(40099)
Alkaline-earth metals promote propane dehydrogenation with carbon dioxide through geometric effects: Altering the reaction pathway by unknow(32736)
Induced iron vacancies boosting FeOOH loaded on sustainable Fenton-like collagen fiber membrane for efficient removal of emerging contaminants by unknow(32511)
Efficient electric-field-assisted photochemical conversion of methane to n-propanol exclusively over penetrated TiO2Ti hollow fibers by Guanghui Feng(32456)
Bi2SiO5 nanosheets as piezo-photocatalyst for efficient degradation of 2,4-Dichlorophenol by Hangyu Shi & Yifu Li & Lishan Zhang & Guoguan Liu & Qian Zhang & Xuan Ru & Shan Zhong(32391)
A novel NDIPTA organic heterojunction photocatalyst with built-in electric field for efficient hydrogen production by Jiahui Yang & Baojun Ma & Yongfa Zhu(32367)
Enhanced conversion of methane to liquid-phase oxygenates via hollow ferrite nanotube@horseradish peroxidase based photoenzymatic catalysis by Jun Duan & Shiying Fan & Xinyong Li & Shaomin Liu(32333)
Ordered macroporous superstructure of defective carbon adorned with tiny cobalt sulfide for selective electrocatalytic hydrogenation of cinnamaldehyde by Xiao-Shi Yuan & Sheng-Hua Zhou & San-Mei Wang & Wenbo Wei & Xiaofang Li & Xin-Tao Wu & Qi-Long Zhu(32260)
What's Done in Darkness by Kayla Perrin(27152)
Topological analysis of non-conjugated ethylene oxide cored dendrimers decorated with tetraphenylethylene: Insights from degree-based descriptors using the polynomial approach by A Theertha Nair & D Antony Xavier & Annmaria Baby & S Akhila(26533)
Investigation of mechanical and self-healing properties of hydroxyl-terminated polybutadiene functionalized with 2-ureido-4-pyrimidinone by Mohsen Kazazi & Mehran Hayaty & Ali Mousaviazar(26461)