code将文件部署到iPad应用程序的Documents文件夹中

code将文件部署到iPad应用程序的Documents文件夹中

本文介绍了从Xcode将文件部署到iPad应用程序的Documents文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPad Xcode项目中,我在资源"组文件夹中有一个文件.在iPad上部署时,它转到应用程序文件夹 ... AFF9-8A934F9408B3/MyApp.app ,但我需要它转到 ... AFF9-8A934F9408B3/Documents .我该怎么办?

In my iPad Xcode project I have a file located inside Resources group folder. When deploying on iPad it goes to the Application folder ...AFF9-8A934F9408B3/MyApp.app, but I need it to go to ...AFF9-8A934F9408B3/Documents. How can I do that?

推荐答案

作为部署的一部分,您不能直接将文件放入设备上应用程序的文档文件夹中.但是,您可以将它们从(只读)捆绑软件复制到应用程序的文档文件夹中.

You can't directly place files into an application's document folder on the device as a part of the deployment. However, you can copy them from your (read only) bundle into the application's document folder.

要获取对捆绑商品的引用,可以使用:

To obtain a reference to an item in your bundle, you can use:

NSBundle *appBundle = [NSBundle mainBundle];
NSString *bundlePath = [appBundle pathForResource:@"XXXX" ofType:@"xxx"];

然后,您可以像往常一样加载并保存数据.以下问题(除其他之外)中有关于此过程的更多信息: iphone复制文件夹从捆绑包到文档

You can then load the data and save it as you would normally. There's more info on this process in the following question (amongst others): iphone copying folder from bundle to documents

这篇关于从Xcode将文件部署到iPad应用程序的Documents文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 22:46