XCode的Resources文件夹中我文件的物理路径(适用于IOS) [英] the physical path for my files inside the Resources folder of XCode (for IOS)

查看:367
本文介绍了XCode的Resources文件夹中我文件的物理路径(适用于IOS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为iPad开发一个应用程序.我想访问资源"文件夹中的文本文件!我这样做的方式如下:

I'm developing an application for iPad. I want to access a text file inside the Resources folder! I'm doing that in following way:

 NSString* filePath = @"/Users/net4uonline/Desktop/slots2/paylines.txt";

现在,如果我将整个项目从桌面移动到其他地方,我知道这将无法工作.因此,有没有办法为该文件提供相对路径而不是当前路径.也许像下面这样?

Now, if I move my whole project from Desktop to somewhere else I know this won't work. So, is there any way to give a relative path for this file instead of the current path. Maybe like the following?

NSString* filePath = @"Resources/paylines.txt";

我知道这行不通,但是由于我的文件始终位于Resources文件夹中,所以我认为这可能行得通!

I know this won't work but as my file is always going to reside inside the Resources folder, so I thought this might work!

推荐答案

我想您正在寻找

I guess you are looking for NSBundle and pathForResource:ofType: method, aren't you?

这篇关于XCode的Resources文件夹中我文件的物理路径(适用于IOS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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