問題描述
有沒有辦法阻止您的應(yīng)用程序數(shù)據(jù)(文檔文件夾內(nèi)容)同步到 iCloud?(然后將其存儲在 Caches 目錄中,因為 iOS5 中的新問題是 那)我的應(yīng)用程序需要在設(shè)備上存儲數(shù)據(jù),但出于安全原因,它不能同步到任何第 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
您可以使用以下方法設(shè)置不備份"擴(kuò)展屬性.每當(dāng)您創(chuàng)建不應(yīng)備份的文件或文件夾時,將數(shù)據(jù)寫入文件,然后調(diào)用此方法,將 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-存儲/
這篇關(guān)于禁用 iCloud 同步的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!