将内容从XCode预加载到Documents或Library目录中

白饭

我正在构建一个需要预加载内容的iPhone应用程序。呈现此内容是为了测试用户的知识,但用户不会对其进行修改。内容包括专有图像文件和pdf文件。

据我了解,最佳实践是将其存储在应用程序的Library或Documents目录中(请告知此假设是否正确)。在该应用程序的未来版本中,我可能希望通过API上传其他(而非替代)内容,但这不是初始版本的一部分。

我已经看过许多关于获取应用程序文档和库目录的路径以及对其进行读写的帖子和教程。这一切都是好和有用的,但不是我在这里寻找的东西。

我想将内容预先加载到Documents和/或Library目录中,以便最初用于模拟器,以在模拟器中测试应用程序;最终到发行版本。我本以为不用编写代码就可以通过XCode做到这一点。

我无法在Stack Overflow或网上的其他地方找到解决方案。欢迎任何指针,链接,解决方案。我在Swift 4.2中使用XCode 10.3。

请参阅《文件系统编程指南:文件系统基础知识》,该指南向我们展示:

在此处输入图片说明

The “data container” (including the Documents and the various Library folders) is for content generated/saved by the app. When, in Xcode, you mark resources as being part of the target, that becomes part of the bundle, and your app can retrieve it from there at runtime.

Theoretically, yes, you could copy data from the bundle to the Documents and/or Library folders, but, yes, you would have do that programmatically. It seems a bit wasteful to have two copies of these resources on the device, but you can do whatever you want. Generally, though, resources included in the bundle would just be be opened directly from there at runtime, not copying it to the data container (except for those cases where you would need to change it, because bundle contents are read-only).

仅供参考,有关文件系统的其他信息,请参阅iOS Storage Best Practices视频。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

将下载的图像加载到Documents目录中(IOS 10,xcode 8.1,Swift 3.0)

来自分类Dev

Ansible:将目录中文件的内容加载到dict中

来自分类Dev

将内容加载到Blazor TabControl中

来自分类Dev

将()网站内容从子目录加载到页面中

来自分类Dev

将()网站内容从子目录加载到页面中

来自分类Dev

CQ5将组件预加载到parsys中

来自分类Dev

NextJS,将Redux数据预加载到getServerSideProps中

来自分类Dev

CQ5将组件预加载到parsys中

来自分类Dev

如何将文件预加载到内存中?

来自分类Dev

如何将数据预加载到laravel会话中?

来自分类Dev

将预训练的词嵌入加载到 Tensorflow 模型中

来自分类Dev

如何将模块预加载到 python 脚本中?

来自分类Dev

从href中的数据将内容加载到div中

来自分类Dev

jQuery将内容加载到firefox中的脚本标签中

来自分类Dev

从href中的数据将内容加载到div中

来自分类Dev

将图像从文档目录异步加载到UICollectionView中

来自分类Dev

将所有部分加载到目录中

来自分类Dev

如何将目录加载到文件系统缓存中?

来自分类Dev

将所有lua文件加载到目录中

来自分类Dev

将网格面板加载到内容面板中

来自分类Dev

将JSON内容加载到流星模板中

来自分类Dev

如何从变量将HTML内容加载到UWP WebView中

来自分类Dev

通过jQuery Ajax将内容动态加载到TinyMce中

来自分类Dev

将文件内容加载到C ++结构中

来自分类Dev

将网格面板加载到内容面板中

来自分类Dev

将html或div的内容加载到div中

来自分类Dev

将JSON内容加载到流星模板中

来自分类Dev

jQuery / Ajax将外部页面加载到内容div中

来自分类Dev

Angular - 单击时将内容动态加载到 HTML 中

Related 相关文章

热门标签

归档