iOS 5 does not allow to store downloaded data in Documents directory?(iOS 5 不允许将下载的数据存储在 Documents 目录中?)
问题描述
我通过将目标 iOS 设置为 4 为我的客户创建了一个应用程序.
但由于应用程序仍未提交到 Apple Store,我的客户计划将其升级到 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 目录中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iOS 5 不允许将下载的数据存储在 Documents 目录中
基础教程推荐
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01