gpt4 book ai didi

ios - 意外数据保存在iCloud中

转载 作者:行者123 更新时间:2023-12-01 16:26:33 26 4
gpt4 key购买 nike

我的一个应用程序由于以下原因而被拒绝:

2.23-应用必须遵循iOS数据存储准则,否则将被拒绝
2.23详细信息
在启动和下载内容时,您的应用程序在用户的iCloud上存储了103.72 MB,这不符合iOS数据存储准则。

我检查了iPhone,我的应用程序确实将200+ MB的数据保存到了iCloud。但是,我非常确定我的应用程序中的所有数据都保存在Core Data中,并且该应用程序甚至没有在“功能”选项卡中打开iCloud。那么有没有办法找出这些数据来自何处?还是您可以提出一些可能导致这种情况的建议,以便我调查一下?
编辑
抱歉,我错过了Apple的反馈意见:

有关防止文件备份到iCloud和iTunes的其他信息,请参阅Technical Q&A 1719: How do I prevent files from being backed up to iCloud and iTunes

因此,我认为审阅者的实际含义是已经备份了一些不应该备份到iCloud的数据,所以我要做的就是这样:

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

最佳答案

这是很常见的问题。

您可以在application:didFinishLaunchingWithOptions:中使用以下代码来查看有关iCloud备份的每个项目的权限:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths 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同步,则可以将 NSURLIsExcludedFromBackupKey的资源值设置为 YES,而不是将这些文件保存在其他位置,以免这些文件被iCloud备份

像这样:
NSURL *URL = [NSURL fileURLWithPath:photoPath];
[URL setResourceValue:@(YES) forKey:NSURLIsExcludedFromBackupKey error:nil];

关于ios - 意外数据保存在iCloud中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34975600/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com