Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable iCloud sync [duplicate]

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).

like image 993
BadPirate Avatar asked Oct 14 '11 19:10

BadPirate


1 Answers

From: https://developer.apple.com/library/ios/#qa/qa1719/_index.html

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;
}

More information can be found: https://developer.apple.com/icloud/documentation/data-storage/

like image 90
BadPirate Avatar answered Sep 20 '22 20:09

BadPirate