iPhone文档目录和UIFileSharingEnabled,隐藏某些文档

发布于 2024-09-03 18:21:56 字数 107 浏览 0 评论 0原文

我希望用户能够访问文档目录中的文件,但正在使用核心数据,并且不希望用户能够访问存储(sqllite db),我可以在仍然允许文件共享的情况下对用户隐藏它吗,或者我可以将其放在另一个仍会备份的目录中吗?

I want the user to be able to access the files in the documents directory but am using core data and dont want the user to be able to access the store (the sqllite db), can i hide it from the user while still allowing file sharing, or can i put it in another directory where it will still get backed up?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

残花月 2024-09-10 18:21:56

FrenchKiss Dev给出的答案不正确。用户仍然可以在 iTunes 中看到“.data”目录,并将其及其内的所有文件保存在本地。

相反,请将私有文档存储在 Library/Preferences

根据苹果的说法:

除了之前记录的目录之外,整个
/Library 目录在期间始终保留
更新和备份,/Library/Caches 除外。
因此,应用程序可以在中创建自己的目录
/Library/ 和这些目录将被保留在
备份和跨更新。为了最大限度地减少名称冲突的风险,
我们建议您仔细命名该目录。例如,一个
名为 Private Documents 的目录将是一个不错的选择。 你应该
将您不想共享的任何文件存储到库/首选项

The answer given by FrenchKiss Dev is not correct. The user will still be able to see the ".data" directory in iTunes and save that locally with all the files inside it.

Instead, store private documents in Library/Preferences

According to Apple:

In addition to the directories documented previously, the entire
/Library directory has always been preserved during
updates and backups, except for /Library/Caches.
Because of this, applications can create their own directories in
/Library/ and those directories will be preserved in
backups and across updates. To minimize the risk of name collisions,
we recommend that you name this directory carefully. For example, a
directory named Private Documents would be a good choice. You should
store any files you don't want to share to Library/Preferences
.

千鲤 2024-09-10 18:21:56

在文档目录中,创建一个名称以点开头的子目录。例如:

.data

编辑:请停止降级此答案!
这个答案在当时是正确的(记住那是在 iPad 真正可用之前!而且在这个问题上有很多困惑,我们仍然希望 iPad 出现在 Finder 的共享设备中......) .
今天(2012 年 4 月)它仍然可以在 Mac 上运行,但不能在 Windows 上运行(以点开头的目录名称在 Windows 中没有任何意义)。

无论如何,这个共享文档功能是一团糟。后来他们修复了这个问题,说“私人文档”应该存储在库文件夹中,而不是文档文件夹中。但请记住,在 iPad 出现之前,开发人员就已经在使用 Document 文件夹了。
不要因为苹果的错误而责怪我。
Stack Overflow 应该有一种方法将答案标记为已过时。
API 发生变化、得到修复,从而使答案变得过时。

In the documents directory, create a subdirectory which name starts with a dot. For example:

.data

EDIT: Please stop downgrading this answer !
This answer was correct at the time (remember that it was before the iPad was actually available! And there was a lot of confusion on the matter, we were still hoping for the iPad to appear in the shared devices in the Finder...).
Today (April 2012) it is still working on the Mac but not on Windows (starting a directory name with a dot means nothing in Windows).

Anyway, this Shared Document feature is a mess. Later they fixed it by saying that "Private Documents" should be stored in the Library Folder not in the Documents folder. But remember that developers were already using the Document folder before the iPad came.
Don't blame me for Apple mistakes.
Stack Overflow should have a way to mark an answer as obsolete.
API changes, get fixed, and it renders answers obsolete.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文