4

我开发了一个应用程序,可以从网上下载 mp3 文件(大小接近 6 到 8 mb)并存储在 NSDocumentDirectory 中。我的应用程序今天被拒绝并说

"Apps must follow the iOS Data Storage Guidelines or they will be rejected"


 We found that your app does not follow the iOS Data Storage Guidelines, which is
 required per the App Store Review Guidelines. The iOS Data Storage Guidelines 
 indicate that only content that the user creates using your app, e.g., documents,
 new files, edits, etc., may be stored in the /Documents directory - and backed up
 by iCloud. 

 Temporary files used by your app should only be stored in the /tmp directory; 
 please remember to delete the files stored in this location when the user exits 
 the app. "

我曾经将音乐文件存储在 NSDocumentDirectory 中。所以,这是我第一次这样做,我无法弄清楚实际问题。我应该怎么做才能重新提交我的应用程序以供接受。

这是我的代码

 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);



 NSString *documentsDirectoryPath = [[paths objectAtIndex:0]stringByAppendingPathComponent:[NSString stringWithFormat:@"psalmsMusic%d.mp3",i]];
NSLog(@"ddddddd psalmsMusic%d.mp3",i);
i++;


 NSLog(@"path %@",documentsDirectoryPath);
 [receivedData writeToFile:documentsDirectoryPath atomically:YES];

真的需要一些帮助。

4

7 回答 7

7

我的应用程序出于同样的原因被拒绝,解决方案非常简单,而不是将下载的文件保存到 Documents 目录中,您必须将它们保存到缓存目录中,该目录是一个临时目录,不会备份到 iCloud 并且可以在某些情况下被操作系统随机删除...这是您将文件保存到缓存目录的方式

NSString *filePath = [[self applicationCachesDirectory] stringByAppendingPathComponent:fileName];


BOOL flag = [[NSFileManager defaultManager] createFileAtPath:filePath contents: receivedData attributes:nil];

编辑

NSString *filePath = [[self applicationCachesDirectory]  stringByAppendingPathComponent:[NSString stringWithFormat:@"psalmsMusic%d.mp3",i]];
NSLog(@"ddddddd psalmsMusic%d.mp3",i);
i++;
BOOL flag = [[NSFileManager defaultManager] createFileAtPath:filePath contents: receivedData attributes:nil];
if ( flag )
  NSLog("success");
于 2012-07-12T05:24:11.110 回答
3

Apple 希望减少您的备份占用空间。

首先,停止使用文档。这不合适。

如果您能够相当容易地再次下载文件,则应将它们存储在不会备份的地方。我建议缓存。如果它们被清除,您应该重新下载它们。

如果很难再次下载它们,您应该将它们存储在 Library 文件夹中的其他位置。

您可以使用以下命令找到 Caches 目录:

NSArray *paths = NSSearchPathForDirectoriesInDomains(
                        NSCachesDirectory, NSUserDomainMask, YES);

基本上,这就是你现在所拥有的,但不是NSDocumentDirectory你使用NSCachesDirectory.

如果您控制文件名,这很好。如果你不这样做,你可能应该创建一个子目录并从那里工作,这样你就不会与任何东西发生冲突。

于 2012-07-12T05:15:13.247 回答
3

一旦 iCloud 在 Apple 中实现,文档目录数据就与 iCloud Storage 有某种关联。因此,Apple 现在拒绝在文档目录中使用大量数据存储的应用程序。

您需要将数据存储在其他位置。将 MP3 文件存储在其他位置。

此链接可能对您有所帮助。

http://www.techotopia.com/index.php/Working_with_Directories_on_iOS_4_%28iPhone%29

我希望它能解决你的问题。

另一个正在跟随…………

iOS 数据存储指南指出,只有用户使用您的应用程序创建的内容,例如文档、新文件、编辑等,可以存储在 /Documents 目录中 - 并由 iCloud 备份。

您的应用程序使用的临时文件应仅存储在 /tmp 目录中;请记住在用户退出应用程序时删除存储在此位置的文件。可以重新创建但必须保留以使您的应用程序正常运行的数据 - 或者因为客户希望它可以离线使用 - 应该使用“不备份”属性进行标记。对于 NSURL 对象,添加 NSURLIsExcludedFromBackupKey 属性以防止相应文件被备份。对于 CFURLRef 对象,使用相应的 kCFURLIsExcludedFromBackupKey 属性。

有关详细信息,请参阅http://developer.appcelerator.com/question/134926/ipad-app-rejected-ios-data-storage-guidelines

于 2012-07-12T05:14:50.343 回答
1

您不能存储,NSDocumentDirectory因为此目录现在用于与 iCloud 同步。但是您可以使用NSCachesDirectory或使用临时目录作为存储音乐文件的苹果评论状态。

于 2012-07-12T05:15:37.697 回答
1

指导方针说只有不能从互联网上重新创建(下载)的重要文件才应该进入文档目录,因为这是

于 2012-07-12T05:18:11.237 回答
1

根据 iOS 存储指南(可在http://developer.apple.com/icloud/documentation/data-storage/找到),您应该将所有用户生成的内容放在 Documents 目录中,并将所有可重新下载的内容放在缓存目录。所以你应该没问题把 sqLite 数据库放在那里。

这方面的背景是,从 iOS 5 开始,Documents 目录已备份到 iCloud。由于许多应用程序倾向于将其完整数据存储在那里,iCloud 备份变得相当大,这会占用可用空间并产生网络流量,这反过来又会激怒用户,因为他/她想知道为什么。为了缓解这种情况,Apple 现在似乎更仔细地查看了保存在 Documents 目录中的内容,以及这是否可能是可再生的内容(例如可下载的文件)。

请注意,当设备上的可用空间不足时,操作系统可以并且将在 iOS 5 上清除 Caches 目录。因此,您的应用程序不能再假设所有内容都像以前一样存在,而是每次访问缓存中的内容时都必须重新检查。

希望这可以帮助...!

于 2012-07-12T06:15:53.980 回答
0

由于同样的原因,我的应用程序也被拒绝了 - (2.3)

尝试这个 -

NSString *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);

这样做的好处是,只要您的设备将与云同步,那时应用程序数据将不会同步,因为它在 NSCachesDirectory 而不是 NSDocumentDirectory 中。

缺点是,无论何时您将使用您的设备,并且您的设备内存较少。那么 CPU 可能会清除缓存以获取可用空间。因此,如果您有任何数据供离线使用,您可能会丢失。

2)如果你不能使用 NSCachesDirectory (可能是因为你的数据太重要了)那么你可以用这种方式 -

使用此方法并提供您的数据库路径 - 'addskipbackupattributetoitematurl'

浏览此链接 -如何使用 addSkipBackupAttributeToItemAtURL API?

于 2015-02-13T13:00:19.163 回答