【发布时间】:2012-06-27 15:03:33
【问题描述】:
我的应用程序被拒绝,因为似乎 7 mb 存储在文档文件夹中,并且它们会自动发送到 icloud。所以我已经通过这种方法循环了所有将写入文档文件夹的文件:
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL {
const char* filePath = [[URL path] fileSystemRepresentation];
const char* attrName = "com.apple.MobileBackup";
if (&NSURLIsExcludedFromBackupKey == nil) {
// iOS 5.0.1 and lower
u_int8_t attrValue = 1;
int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
return result == 0;
}
else {
// First try and remove the extended attribute if it is present
int result = getxattr(filePath, attrName, NULL, sizeof(u_int8_t), 0, 0);
if (result != -1) {
// The attribute exists, we need to remove it
int removeResult = removexattr(filePath, attrName, 0);
if (removeResult == 0) {
NSLog(@"Removed extended attribute on file %@", URL);
}
}
// Set the new key
NSError *error = nil;
[URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];
return error == nil;
}
我的应用程序的 1.1 版在此代码实施后获得批准。上周我尝试发送同一个应用程序的 1.2 版(文件管理没有任何变化,存储在文档文件夹中的所有文件都通过 addSkipBackupAttributeToItemAtURL 方法循环)。出于同样的原因,我的应用再次被拒绝。我无法将我的文件移动到临时或缓存文件夹,因为我的应用程序无法完全恢复文件(此文件之一是 db,恢复 db 意味着丢失任何用户插入的数据),所以这不是解决方案.无论如何我在代码中发现了一个问题,这就是我调用该方法的方式:
[self addSkipBackupAttributeToItemAtURL:[NSURL fileURLWithPath:fullPath]];
在 ios 5.1 中使用 [NSURL fileURLWithPath:fullPath] 设备会返回错误,并且似乎无法创建该属性。如果我使用 [NSURL URLWithString:defaultStorePath] 更改 nsurl 的初始化,5.1 的设备似乎正确添加了该属性。
使用 ios 5.0.1 all is reversed,[NSURL URLWithString:defaultStorePath] 返回错误,而 [NSURL fileURLWithPath:fullPath] 工作。
也许我可以检查 ios 版本并设置适当的 nsurl 初始化,但这仍然是个问题。在拒绝解释中我读到:
特别是,我们发现在启动和/或内容下载时,您的应用存储 7mb。要检查您的应用存储了多少数据:
- 安装并启动您的应用
- 转到设置> iCloud > 存储和备份> 管理存储
- 如有必要,点按“显示所有应用”
- 检查应用的存储空间
如果我尝试检查此值,我还会看到 7 mb 以及正确的 nsurl 初始化(当所有属性都设置正确时)。什么是正确的行为?有这个问题的人吗?在苹果建议的应用存储检查之前,我是否必须做一些特定的事情才能让它变得重要?
【问题讨论】:
标签: ios iphone icloud appstore-approval