iOS下载文件,保存路径. 防止…
来源:互联网 发布:算法工程师学什么专业 编辑:程序博客网 时间:2024/05/22 10:52
#pragma mark -
- (BOOL)addSkipBackupAttributeTo
{
}
#pragma mark - Setting the Extended Attribute on iOS 5.0.1
#import
- (BOOL)addSkipBackupAttributeTo
{
}
- (NSURL *)getDefaultDir
{
float fVersion = 0.0;
if(strVersion.length > 0)
fVersion = [strVersion floatValue];
}
icloud备份,这个东西比较烦人,但从用户的角度,好多东西确实没必要备份。
Apps must follow the iOS Data Storage Guidelines or they will berejected
2.23
We found that your app does not follow the iOS Data StorageGuidelines, which is required per the App Store ReviewGuidelines.
In particular, we found that on launch and/or content download,your app stores 13.4 MB. To check how much data your app isstoring:
- Install and launch your app
- Go to Settings > iCloud > Storage & Backup > ManageStorage
- If necessary, tap "Show allapps"
- Check your app's storage
The iOS Data Storage Guidelines indicate that only content that theuser creates using your app, e.g., documents, new files, edits,etc., may be stored in the /Documents directory - and backed up byiCloud.
Temporary files used by your app should only be stored in the /tmpdirectory; please remember to delete the files stored in thislocation when the user exits the app.
Data that can be recreated but must persist for proper functioningof your app - or because customers expect it to be available foroffline use - should be marked with the "do not back up" attribute.For NSURL objects, add the NSURLIsExcludedFromBacku
For more information, please see Technical Q&A 1719: How do Iprevent files from being backed up to iCloud andiTunes?.
It is necessary to revise your app to meet the requirements of theiOS Data Storage Guidelines.
(说的很明白了,让你把离线数据加上离线的属性
解决方案:
file:///Users/bjrd_mac/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS6.0.iOSLibrary.docset/Contents/Resources/Documents/index.html#qa/qa1719/_index.html
How do I prevent files from being backed up to iCloud andiTunes?
Q: My app has a number of files that need to bestored on the device permanently for my app to function properlyoffline. However, those files do not contain user data and don'tneed to be backed up. How can I prevent them from being backedup?
A:
Important:
iOS 5.1 and later
Starting in iOS 5.1, apps can useeither
Listing1
- (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;
}
iOS 5.0.1
If your app must support iOS 5.0.1, you can use the followingmethod to set the "do not back up" extended attribute. Whenever youcreate a file or folder that should not be backed up, write thedata to the file and then call this method, passing in a URL to thefile.
Warning: NSURL
CFURL
Listing2
#import
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);
const char* filePath = [[URL path] fileSystemRepresentation];
const char* attrName = "com.apple.MobileBackup";
u_int8_t attrValue = 1;
int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
return result == 0;
}
iOS 5.0
It is not possible to exclude data from backups on iOS 5.0. If yourapp must support iOS 5.0, then you will need to store your app datain Caches
Caches
DocumentRevision History
Updated for iOS 5.1
2011-11-10-Fixed critical bug in code snippet.
New document that describes how an app can prevent files from beingbacked up to iCloud and iTunes.
- iOS下载文件,保存路径. 防止…
- iOS文件,保存路径. 防止加到iCloud备份
- iOS--- 文件路径保存
- iOS 文件路径以及保存
- Android下载文件保存到路径
- Unity商店下载的文件保存路径
- java下载excel文件源码(可选择保存文件路径)
- unity asset astore 下载文件保存路径 [Mac]
- 根据网络路径批量下载文件保存到本地
- java从服务器下载文件,可选择保存路径
- 改变文件保存路径
- TextNut文件保存路径
- Android 保存文件路径
- 下载时保存路径对话框
- iOS 开发-AFNetworking Block下载文件保存到沙盒
- a href 下载 文件
- PHP下载保存文件
- iOS数据保存-文件保存
- 关于iOS6.0上使用Xib以及对低版本…
- How to add environment var…
- 常见证书格式和转换
- 详解在IOS后台执行
- iOS文件加密(Protecting Dat…
- iOS下载文件,保存路径. 防止…
- iOS开发流程总结
- 优秀开源代码解读:JS与iOS N…
- iOS应用内置AppStore以及iOS Safar…
- xcode4.5.1、iphone5、ios6&…
- IOS开发之----获取本机号码…
- 转: ios与android语音互通…
- iOS XCode自动化编译相关
- 哪些开源引擎可以进行Android游戏开发