iPhone開發:如何阻止檔案被iTunes和iCloud同步 How do I prevent files from being backed up to iCloud and iTunes?
阿新 • • 發佈:2019-02-16
先閱讀官方說明:
使用方法:
#import “sys/xattr.h”
另外補充一下,對這個特性的測試要有耐心,因為icloud識別應用程式裡要同步的資料量大小顯示要等幾秒(菊花。。),
參考文件:apple官方文件,
- (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;
}
- (void)addSkipBackupAttributeToPath:(NSString*)path {
u_int8_t b = 1;
setxattr([path fileSystemRepresentation], “com.apple.MobileBackup”, &b, 1, 0, 0);
}