0

我是 iOS 开发的新手。我的应用程序被拒绝,因为它必须遵循 iOS 数据存储指南。我已经在 Stack Overflow 上阅读了一些答案,并且我已经阅读了一些博客。

我在我的 appdelegate.m 中使用以下方法来停止 icloud 备份。我的数据库大小是 79mb。

- (BOOL)addSkipBackupAttributeToItemAtPath:(NSString *)path {
    NSURL *url = [NSURL fileURLWithPath: path];
    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;
}

我也使用过这段代码:

 NSArray *pathsa = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
    NSString *basePath = ([pathsa count] > 0) ? [pathsa objectAtIndex:0] : nil;
    NSArray *documents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:basePath error:nil];
    NSURL *URL;
    NSString *completeFilePath;
    for (NSString *file in documents) {
        completeFilePath = [NSString stringWithFormat:@"%@/%@", basePath, file];
        URL = [NSURL fileURLWithPath:completeFilePath];
        NSLog(@"File %@  is excluded from backup %@", file, [URL resourceValuesForKeys:[NSArray arrayWithObject:NSURLIsExcludedFromBackupKey] error:nil]);
    }

但它仍然在 iCloud 存储中显示 109 MB。

4

0 回答 0