Role of iCloud for developers (one of the new features of ios5)

Source: Internet
Author: User

Recently, when debugging an application, I found that some buttons did not work under ios5. I checked some documents and found that some methods of uiviewcontroller have changed, when I was writing a new application, I would like to take a good look at the new functions of IOS. Now it seems that I want to learn more in advance. I wrote this article mainly to learn some records of the new API of IOS, this is also the first article of this blog. At the same time, this blog is definitely mainly about mobile development, especially iOS development. I have been studying things for the past few years, but the article will be biased towards basic and fundamental things, there won't be too many specific code. After all, Google's code has come out, but the principle is not necessarily the same for everyone. Therefore, writing it down is also a learning experience and accumulation.

API stored by iCloud


For developers, there are two main functions involved in iCloud storage: one is iCloud document storage, which uses iCloud to store user files, such as saving files generated by users when using applications, for example, database files. Second, iCloud key-value data storage uses the cloud storage key-value pair to save the configuration information of some programs. Generally, only dozens of KB of data size can be stored, I guess ibooks uses this method for bookmarks synchronization and other functions.

Pay attention to the automatic backup feature of iCloud. If you enable this feature in ios5, iclound automatically backs up your applications as a developer, pay attention to the file storage directory. Because the files in the document directory and library directory (except the caches files in this directory) under the application home directory are automatically backed up to iCloud, you can store large temporary files or files that can be rebuilt at any time in the library \ caches directory, which can help you save your iCloud space and provide a user experience. In addition, I believe everyone is concerned about how to ensure the security of applications stored in iCloud, and whether the data stored by unused applications can be effectively isolated? In this regard, iCloud introduces the sandbox concept in iOS, that is, every application has a sandbox in iCloud, And the access scope is limited to this, so as to ensure data security and isolation.

However, ios5 also has a mechanism worth noting, that is, when the device capacity is insufficient, the system will automatically clear the content of the cache file or temporary directory. Of course, the contents in the library \ caches directory will be cleared, so it is a dilemma for developers. However, from this mechanism, Apple wants to minimize the storage size of applications locally. However, for China's network conditions, network-dependent applications should not yet be mature. But for developers, when reading files under the library \ caches directory, they should at least make a judgment to see if the files are not there, so as to avoid program crash.

It should also be noted that if our developers are already using the above two iCloud APIs to store some files, these files will not be automatically backed up to iCloud.

Supplement:

IOS 5.0.1 provides a new feature that sets an attribute for a file, telling the system that the file will not be deleted even when it is low-storage, such files will not be backed up when users back up to iCloud or iTunes, so developers need to manually manage them. In addition, files with this attribute set can maintain the above features no matter which directory They are placed in.

The implementation code is as follows:

View
Plain

  1. # Include <sys/xattr. h>
  2. -(Void) addskipbackupattributetofile: (nsurl *) URL
  3. {
  4. U_int8_t B = 1;
  5. Setxattr ([[URL path] filesystemrepresentation], "com. Apple. Mobile
  6. Backup ", & B, 1, 0, 0 );
  7. }


Reference: What's
New in IOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.