App shelves, icloud stores too much content.

Source: Internet
Author: User

Problem Description: My DB image MP3 file is copied to the/documents directory when the user launches the app.
In particular, we found this on launch and/or content download, your app stores 2.02 MB. To check how much data your app is storing:

-Install and launch your app
-Go to Settings > ICloud > Storage & Backup > Manage Storage
-If necessary, tap "Show all Apps"
-Check Your app ' s storage
The main English is that, in addition to the user's own creation of files, other files such as the app's own offline files, can not be saved to icloud, which is Apple's storage rules.
Problem solving:
1, it is best not to put the app's own generated files and user files in a file directory, easy to get the path later.
2. How to prevent files from being backed up to icloud and itunes
Starting with iOS 5.1, apps can use the Nsurlisexcludedfrombackupkey or Kcfurlisexcludedfrombackupkey file properties to prevent files from being backed up. These APIs are additional properties that are set directly through the old, deprecated way. All running on iOS5.1 should use these API packages to prevent files from being backed up.
Prevent files from being backed up on iOS5.1

-(BOOL) Addskipbackupattributetoitematurl: (Nsurl *) URL

{

ASSERT ([[Nsfilemanager Defaultmanager] Fileexistsatpath: [URL Path]]);

Nserror *error = nil;

BOOL success = [URL setresourcevalue: [NSNumber Numberwithbool:yes]

Forkey:nsurlisexcludedfrombackupkey Error: &error];

if (!success) {

NSLog (@ "Error excluding%@ from backup%@", [URL lastpathcomponent], error);

}

return success;

}

How does the Addskipbackupattributetoitematurl method work?
Then change this in the app DELEGATE.M:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
documentsDir = [paths objectAtIndex:0];
[self addSkipBackupAttributeToItemAtURL:[NSURL fileURLWithPath:documentsDir];
这样就可以保证app的documents文件内容不备份到icloud上,其他文件目录同理。

App shelves, icloud stores too much content.

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.