如何从Xcode的“支持文件”访问文件组,在应用程序? [英] How do I access a file from Xcode’s "Supporting Files" group, in app?

查看:163
本文介绍了如何从Xcode的“支持文件”访问文件组,在应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,现在我几乎已经完成了电子邮件,在数据录入流程结束时,两个.pdf文件。其中一个是从输入的数据生成的,另一个是在每个实例中都是相同的静态文件。

I have an app that I've almost finish now that emails, at the end of a data entry flow, two .pdf files. One of these is generated from the entered data, the other is a static file that will be the same in every instance.

第一个pdf生成正确,它被保存到应用程序的文档文件夹,我已成功附加到一个电子邮件发送。这是第二个.pdf,我在应用程序的外部创建的,并且正在尝试添加,这使我很悲伤。

The first pdf is generating fine, it's saved to the apps 'documents' folder, and I have successfully attached to to an email for sending. It's the second .pdf, one that I made externally to the app and am trying to add, that is causing me grief.

我已将它添加到支持我的Xcode项目中的文件的文件夹,但经过这里和其他地方在网上搜索了很多,我不能解决如何访问该文件,以便能够添加它作为电子邮件的附件。
从Xcode的Organizer中下载应用程序的数据后,我可以看到这个文件不在任何地方;大概是因为Xcode可以看到这个文件没有在任何地方被使用,在构建的时候没有添加它(这是我的一个假设),但是我不知道如何引用它,因为我不知道在哪里这将是引用它!

I've added it to the 'Supporting Files' folder within my Xcode project, but after much searching on here, and elsewhere online, I can't work out how to access that file to be able to add it as an attachment in the email. Having "downloaded" the app's data from the Organizer in Xcode, I can see that the file isn't there anywhere; presumably because Xcode can see that the file isn't being used anywhere, it's not adding it at build time (very much an assumption on my part), but I don't know how to reference it anywhere because I don't know where it will be to reference it!

推荐答案

Xcode不会在您的应用程序包中生成对应于组的任何文件夹。只要确保您的PDF文件存在于您的目标构建阶段的复制包资源中。然后在 [[NSBundle mainBundle] bundlePath] 路径下访问您的资源。

The Xcode does not generate any folders in your app bundle that corresponds to groups. Just make sure that your pdf is present in Copy Bundle Resources in your target's Build Phases. You then access your resource under [[NSBundle mainBundle] bundlePath] path.

这篇关于如何从Xcode的“支持文件”访问文件组,在应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆