iOS 5不允许将下载的数据存储在Documents目录中? [英] iOS 5 does not allow to store downloaded data in Documents directory?

查看:212
本文介绍了iOS 5不允许将下载的数据存储在Documents目录中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过将目标iOS保持为4来为我的客户端创建了一个应用程序。

但是由于该应用程序仍未提交给Apple商店,我的客户计划将其升级到iOS 5.0。

I have made an application for my client by keeping target iOS as 4.
But since the application still not submitted to Apple store, my client is planning to upgrade it for iOS 5.0.

为此,我阅读了来自Apple的指南并发现只有用户生成的数据或者您的应用程序无法重新创建的数据,应存储在/ Documents目录中,其余部分应存储到/ Library / Caches目录

For this I read the guideline from Apple and found that "Only user-generated data or that cannot otherwise be recreated by your application, should be stored in the /Documents directory and rest should be stored to /Library/Caches directory"

在我的应用程序中,我使用的是针对非消费品的应用程序内购买服务器模型。为此,我将所有下载的数据(基本上是书籍或杂志)存储到Documents目录中。数据库也存在于同一目录中,该目录包含有关下载产品的详细信息。

In my application, I am using server model of in-app purchase for non-consumable product. For this I am storing all my downloaded data (which are basically books or magazines) to Documents directory. The Database is also present in the same directory which contains the details about the downloaded products.

我的问题是,

1.我是否必须更改我的代码才能将下载的数据存储到Library / Caches目录而不是Documents目录?

2.我的数据库文件放在哪里(到文档或缓存)?

My question is,
1. Should I have to change my code to store the downloaded data to Library/Caches directory instead of to the Documents directory?
2. Where should my database file be placed (to Documents or Caches)?

如果我把产品放在缓存中,那么我也必须改变检索的逻辑,因为如果记录存在于数据库中,则没有必要更改文件的存在,并在用户单击杂志时直接打开它。

If I put it products in the Caches then I have to change the logic of retrieval also, since it is considered that if record is present in database, there is no need change the existence of the file and it directly opens it when user clicks on the magazine.

请在这个问题上指导我。

提前致谢。

Kindly guide me on this issue.
Thanks in advance.

更新:

我正在为那些仍然不确定这个问题的人更新这个。

使用接受答案的准则,我在2中实现了这个我的申请并将其提交给Apple Store。两者都经过审核批准。

这可能会促使接受答案中建议的解决方案正确无误。

UPDATED:
I am updating this for those who are still not sure about this problem.
Using the guideline of accepted answer, I have implemented this in 2 of my applications and submitted them to Apple Store. Both were approved in review.
This may promote that the solution suggested in the accepted answer is correct.

推荐答案

以下是权衡利弊:


  • 如果您将文件放在Documents目录中,那么它们将备份到iTunes或iCloud,但如果它们太大而且可以再次下载文件,那么Apple可能会拒绝您的应用程序

  • 如果您将文件放在缓存目录中,那么将不会备份,Apple将不会拒绝您的应用。但是,当iOS 5的空间不足时,可以删除其中的所有文件。

  • If you put your files in the Documents directory then they are backed up to iTunes or iCloud but if they are too big and it's possible to download the files again then Apple may reject your app
  • If you put your files in the Cache directory then they won't be backed up and Apple won't reject your app. However, when iOS 5 gets low on space it may delete all the files in there.

但是, iOS 5.0.1中有第三个选项:

However, with iOS 5.0.1 there is a third option:


  • 将文件放入Documents但标记它们以便不备份它们。有一个技术说明( QA1719 )怎么做。

  • Put files in Documents but flag them so that they are not backed up. There's a technote (QA1719) on how to do this.

我想这可能是你的最佳答案。

I think this is probably the best answer for you.

这篇关于iOS 5不允许将下载的数据存储在Documents目录中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆