Disable iCloud sync(禁用 iCloud 同步)
问题描述
有没有办法阻止您的应用程序数据(文档文件夹内容)同步到 iCloud?(然后将其存储在 Caches 目录中,因为 iOS5 中的新问题是 那)我的应用程序需要在设备上存储数据,但出于安全原因,它不能同步到任何第 3 方(包括 Apple).
Is there a way to prevent your application data (Documents folder contents) from being synced to iCloud? (other then storing it in Caches directory because of the new issues in iOS5 with doing that) My Application has need of storing data on the device, but for security reasons it can't be synchronized to any 3rd party (including Apple).
推荐答案
来自:https://developer.apple.com/library/ios/#qa/qa1719/_index.html
您可以使用以下方法设置不备份"扩展属性.每当您创建不应备份的文件或文件夹时,将数据写入文件,然后调用此方法,将 URL 传递给文件.
You can use the following method to set the "do not back up" extended attribute. Whenever you create a file or folder that should not be backed up, write the data to the file and then call this method, passing in a URL to the file.
#include <sys/xattr.h>
- (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;
}
可以找到更多信息:https://developer.apple.com/icloud/documentation/data-存储/
这篇关于禁用 iCloud 同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:禁用 iCloud 同步


- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01