如何将文件放入xcode for Documents开发的Documents文件夹中?

时间:2022-11-07 01:46:11

I would like to put some sample images in the applications Documents directory. 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?).

用户将能够添加自己的图像(将写入Documents文件夹),我宁愿不单独访问示例图像,我只是希望它们预先在Documents文件夹中播种(我假设资源在xcode中首先没有存储在那里?)。

3 个解决方案

#1


3  

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中检查它们是否存在(或在设置中设置布尔标志等),然后从那里创建所需的图像。

#2


2  

This link might be helpful for you http://www.iphonedevsdk.com/forum/iphone-sdk-development/12014-save-file-directly-into-documents-directory-xcode.html

此链接可能对您有所帮助http://www.iphonedevsdk.com/forum/iphone-sdk-development/12014-save-file-directly-into-documents-directory-xcode.html

I also looking answer to that question.

我也在寻找这个问题的答案。

#3


1  

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). For you, you would have to read it from the bundle, and save it into the document folder when the app runs.

我只是看着同样的事情。当您在资源中放置文件时,它将成为您的应用包的一部分。对我来说这很好,因为它是一个数据文件(html)。对于您来说,您必须从捆绑包中读取它,并在应用程序运行时将其保存到文档文件夹中。

#1


3  

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中检查它们是否存在(或在设置中设置布尔标志等),然后从那里创建所需的图像。

#2


2  

This link might be helpful for you http://www.iphonedevsdk.com/forum/iphone-sdk-development/12014-save-file-directly-into-documents-directory-xcode.html

此链接可能对您有所帮助http://www.iphonedevsdk.com/forum/iphone-sdk-development/12014-save-file-directly-into-documents-directory-xcode.html

I also looking answer to that question.

我也在寻找这个问题的答案。

#3


1  

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). For you, you would have to read it from the bundle, and save it into the document folder when the app runs.

我只是看着同样的事情。当您在资源中放置文件时,它将成为您的应用包的一部分。对我来说这很好,因为它是一个数据文件(html)。对于您来说,您必须从捆绑包中读取它,并在应用程序运行时将其保存到文档文件夹中。