不要备份到iCloud,但仍然拒绝

在我的应用程序,我必须存储核心数据数据库和audio文件,所以我解码,把他们在文件目录。 为了防止他们备份,当我第一次启动应用程序时,我把这样的不备份标志

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self addSkipBackupAttributeToItemAtURL:[self applicationDocumentsDirectory]]; } - (NSURL *)applicationDocumentsDirectory { return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; } - (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL { if (&NSURLIsExcludedFromBackupKey == nil) { // iOS <= 5.0.1 const char* filePath = [[URL path] fileSystemRepresentation]; const char* attrName = "com.apple.MobileBackup"; u_int8_t attrValue = 1; int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0); return result == 0; } else { // iOS >= 5.1 return [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:nil]; } } 

但它似乎不起作用 – 我仍然被拒绝:

我们发现您的应用不符合iOS数据存储指南,这是根据App Store评论指南要求的。

特别是,我们发现,在发布和/或内容下载时,您的应用程序存储3.6 MB。 要检查您的应用程序正在存储多less数据:

  • 安装并启动您的应用程序
  • 进入设置> iCloud>存储和备份>pipe理存储
  • 如有必要,请点按“显示所有应用”
  • 检查你的应用程序的存储

另一个问题是,我不能检查 – 我没有看到我的应用程序

设置> iCloud>存储和备份>pipe理存储

也许问题是只有5.0,我不想在这里?

问题是与iOS 5.0,在这个iOS你不应该把不要备份标志不备份标志是在IOS 5.0.1引入我们面对类似的问题,我们的应用程序,它已被拒绝了好几次所以我们不得不做解决不同iOS的问题我们需要支持iOS 5.0,iOS 5.0和iOS 5.0

所以在联系苹果后,我们没有find任何解决scheme,除了在不同的iOS上有不同的path

我们有这样的function:

 + (NSString*) savePath { NSString *os5 = @"5.0"; NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; if ([currSysVer compare:os5 options:NSNumericSearch] == NSOrderedAscending) //lower than 4 { return path; } else if ([currSysVer compare:os5 options:NSNumericSearch] == NSOrderedDescending) //5.0.1 and above { return path; } else // IOS 5 { path = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"]; return path; } return nil; } 

我们使用并仍然使用这个function。

请阅读更多

iOS 5.0

在iOS 5.0上不能从备份中排除数据。 如果您的应用程序必须支持iOS 5.0,则需要将应用程序数据存储在caching中以避免数据被备份。 iOS会在必要时从Caches目录中删除文件,因此如果数据文件被删除,您的应用程序将需要适度地降级。

http://developer.apple.com/library/ios/#qa/qa1719/_index.html