在IOS中存储应用程序数据的正确位置 [英] Right place to store the application data in IOS

查看:110
本文介绍了在IOS中存储应用程序数据的正确位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在将我的应用程序数据(媒体)保存到CacheDirectory,即

Currently i was saving my application data (Media) to the CacheDirectory i.e


/ var / mobile / Applications / BEAFC76C -C450-4A3A-9765-A0385A9580F3 / Library / Caches

事情进展顺利。但最近我收到一个错误报告,表明应用程序数据已被删除。当我搜索它时,我得到了这个 Apple Doc 。根据它,DocumentsDirectory应该是存储用户/应用程序数据的理想位置。

and things were going fine. But recently i got a bug report that the application data has been deleted. When i searched over it, i got this Apple Doc. According to it, DocumentsDirectory should be the ideal place to store the User/Application data.


将用户数据放入/ Documents /。用户数据是您的应用无法重新创建的任何
数据,例如用户文档和
其他用户生成的内容。

Put user data in the /Documents/. User data is any data that cannot be recreated by your app, such as user documents and other user-generated content.

并且不应该使用Cache来存储应用程序无法复制的用户数据。

And Cache should not be used to store the User Data that could not be reproduced by the application.


放入数据缓存/ Library / Caches
目录中的文件。您应该放在此目录中的文件示例包括
(但不限于)数据库缓存文件和可下载的
内容,例如杂志,报纸和地图应用程序使用的内容。您的
应用程序应该能够优雅地处理系统删除缓存数据
以释放磁盘空间的情况。

Put data cache files in the /Library/Caches directory. Examples of files you should put in this directory include (but are not limited to) database cache files and downloadable content, such as that used by magazine, newspaper, and map apps. Your app should be able to gracefully handle situations where cached data is deleted by the system to free up disk space.

什么应该是存储它的理想场所。

What should be the ideal place to store it.

编辑:

我有一个应用程序,允许用户在应用程序中存储视频和照片。为此,我使用了CacheDirectory。但我收到错误报告,数据(视频/照片)被删除。我得出的结论是,数据正在被设备本身删除以提供空间。

I have an application that allows user to store Videos and Photos in the application. For that i used CacheDirectory. But i am getting bug reports that the Data (Videos/Photos) is getting deleted. What conclusion i draw is that the data is being getting delete by the Device itself in order to provide space.

其次我还想提供iTunes共享功能。因此,只有特定文件必须存储在DocumentsDirectory中。有些文件永远不会暴露,有些文件必须共享。应该是存储文件的理想方式。

Secondly i also wanna give the iTunes sharing function. So only the particular files has to be stored in the DocumentsDirectory. Some files can never be exposed and some has has to be shared. What should be the ideal way to store the files.

推荐答案

库/应用程序支持文件夹是您应该使用的文件夹。

Library/Application Support Folder is the folder you should be using.

此目录并不总是存在,因此您可能需要创建它。
您可以启用或禁用要使用itunes备份此数据的天气。

This directory doesn't always exist, and thus you may need to create it. You can enable or disable weather you want to backup this data with itunes or not.

即使启用文件共享,也无法访问此数据。只有您放在Document目录中的数据才会与iTunes共享共享,因此您仍然可以保护您的数据并将其备份。 Apple的文档

This data is not accessible even if you enable file sharing. Only data that you put in Document directory would be shared with iTunes sharing, so you can still protect your data and get it backed up as well. Apple's documentation

这篇关于在IOS中存储应用程序数据的正确位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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