简体   繁体   English

如何将文件放入xcode的Documents文件夹中以进行iPhone开发?

[英]How do I put files into the Documents folder in xcode for iPhone development?

I would like to put some sample images in the applications Documents directory. 我想将一些示例图像放在应用程序的Documents目录中。 Can I put these somewhere in my xcode project or do I have to programmatically add them to the Documents folder from the project resources? 我可以将它们放在xcode项目中的某个地方,还是必须以编程方式将它们从项目资源添加到Documents文件夹中?

Users will be able to add their own images (which will be written to the Documents folder) and I would prefer not to access the sample images separately, I just want them to be pre-seeded in the Documents folder (I'm assuming resources in xcode aren't stored there in the first place?). 用户将能够添加他们自己的图像(将其写入“文档”文件夹),并且我不希望不单独访问示例图像,我只是希望将它们预先植入“文档”文件夹中(我假设资源在xcode中不是首先存储在那里?)。

I think you will need to add the images to your app, and then copy them over on the first boot of the app. 我认为您需要将图像添加到您的应用程序,然后在应用程序的首次启动时将其复制。 Just check if they exist (or set a boolean flag in the settings or something) in applicationDidFinishLaunching and create the images you need from there. 只需检查applicationDidFinishLaunching是否存在(或在设置等中设置布尔标志),然后从那里创建所需的图像。

I just looked into the same thing. 我只是看着同一件事。 When you put a file in your Resources, it will be part of your app bundle. 将文件放入“资源”中后,它将成为应用程序包的一部分。 Which for me is fine, because it's a data file (html). 对我来说这很好,因为它是一个数据文件(html)。 For you, you would have to read it from the bundle, and save it into the document folder when the app runs. 对于您来说,您必须从捆绑软件中读取它,并在应用程序运行时将其保存到文档文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM