Can I add the Do not Back up for the “Document Directory” for iCloud

前端 未结 4 1793
长情又很酷
长情又很酷 2021-01-07 02:24

I had read that I can mark folders with \"do not backup\" attribute with ios 5.1 and later

As i understand, in such case all contents of directory will be excluded f

4条回答
  •  悲哀的现实
    2021-01-07 03:26

    From the Apple docs, for iOS 5.1 or later, you should use this:

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

提交回复
热议问题