gpt4 book ai didi

iphone - 防止备份到 iCloud,以下代码是否正确?

转载 作者:可可西里 更新时间:2023-11-01 06:23:45 24 4
gpt4 key购买 nike

我正在下载许多音频和视频文件并将它们存储在我的主目录中。现在我想“防止备份到 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 版本。如果不是那么请建议正确的方法来做到这一点。谢谢你

最佳答案

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

不,它没有。在其Technical Note introducing the "do not backup" flag , Apple 明确表示

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

他们还告诉您需要为旧版 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.

关于iphone - 防止备份到 iCloud,以下代码是否正确?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8558315/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com