关于苹果审核,防止app文件自动备份到icloud上的方法。

ios5以上的app,都可以用此方法。

 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

    NSArray *Paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

    NSString *path=[Paths objectAtIndex:0];

    [self addSkipBackupAttributeToItemAtURL:[NSURL URLWithString:path]];

}

 

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

}

你可能感兴趣的:(icloud)