防止备份到iCloud,代码是否正确? [英] Prevent Backup to iCloud,is following code correct?

查看:122
本文介绍了防止备份到iCloud,代码是否正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在下载许多音频和视频文件并将其存储在我的主目录中。
现在我想阻止备份到iCloud
所以我为我的每个文件的URL添加了以下代码

I am downloading many audio and video files and stored them in my Home directory. Now i want to "prevent backup to iCloud" so i have added following code for my every file's url

- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL

{

    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版本。
如果没有,那么请建议正确的方法来做到这一点。
谢谢

Can anyone tell me that will this code work for all IOS versions. if not then please suggest the correct way to do this. Thank You

推荐答案


任何人都可以告诉我这个代码适用于所有IOS版本。

Can anyone tell me that will this code work for all IOS versions.

不,它没有。在介绍不备份标志的技术说明中,Apple明确指出

No, it doesn't. In its Technical Note introducing the "do not backup" flag, Apple clearly states that


新的不备份属性仅供iOS 5.0.1或更高版本使用。

The new "do not back up" attribute will only be used by iOS 5.0.1 or later.

他们还会告诉您需要为旧iOS版本做些什么:

They also tell you what you need to do for older iOS versions:


在iOS 5.0及更早版本中,应用程序需要将其数据存储在< Application_Home> / Library / Caches 中,以避免备份。由于旧系统会忽略此属性,因此您需要确保您的应用程序符合您的应用程序支持的所有iOS版本的iOS数据存储指南。

On iOS 5.0 and earlier, applications will need to store their data in <Application_Home>/Library/Caches to avoid having it backed up. Since this attribute is ignored on older systems, you will need to insure your app complies with the iOS Data Storage Guidelines on all versions of iOS that your application supports.

这篇关于防止备份到iCloud,代码是否正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆