阻止备份到 iCloud,以下代码正确吗?
我正在下载许多音频和视频文件并将它们存储在我的主目录中。 现在我想“阻止备份到 iCloud” 所以我为每个文件的 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 版本。 如果没有,请建议正确的方法。 谢谢
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;
}
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,事实并非如此。 Apple 在其介绍“不备份”标志的技术说明中明确指出:
他们还告诉您对于旧版 iOS 版本需要做什么:
No, it doesn't. In its Technical Note introducing the "do not backup" flag, Apple clearly states that
They also tell you what you need to do for older iOS versions:
您可以在 iOS 5.1 或更高版本中使用此代码
You can use this code for iOS 5.1 or later