iOS: Do not back up attribute?

后端 未结 3 1636
难免孤独
难免孤独 2020-12-15 05:20

Our app has recently been rejected for violating iOS Data Storage Guidelines about backing up files on iCloud.

I must mark data with the do not ba

3条回答
  •  星月不相逢
    2020-12-15 06:02

    You can call the following function to pass the path of your "map.sqlite" as NSURL:

    NSURL *url = [NSURL fileURLWithPath:yourSQLitePath];
    [self addSkipBackupAttributeToItemAtURL:url];
    The function is provided in Apple as:
    
    - (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
    {
        assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);
    
        NSError *error = nil;
        BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]
                                  forKey: NSURLIsExcludedFromBackupKey error: &error];
        if(!success){
            NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
        }
        return success;
    }
    

提交回复
热议问题