关于苹果审核,防止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;

}

posted on 2015-01-26 17:11  rankilau  阅读(622)  评论(0编辑  收藏  举报

导航