使用来自[[NSBundle mainBundle] resourcePath]的路径 [英] Working with paths from [[NSBundle mainBundle] resourcePath]

查看:558
本文介绍了使用来自[[NSBundle mainBundle] resourcePath]的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定这是一个非常基本的问题,但是我很难找到有关它的任何信息.

I'm sure it's a very basic problem, but I'm having trouble finding anything about it.

说我的应用放在一个文件夹中,在更多文件夹中,如下所示:

Say I've got my app in a folder, in some more folders, like this:

  • MainFolder> SecondaryFolder> AppBundle.app>所有内容

然后,我要执行的操作是访问"MainFolder"中的文件.我知道我可以使用以下方法获取AppBundle的路径:

Then, what I want to do is access a file that is in the "MainFolder". I know I can get the path of the AppBundle by using:

NSLog(@%@",[[NSBundle mainBundle] resourcePath]);

NSLog(@"%@",[[NSBundle mainBundle] resourcePath]);

我不确定的是如何获取"MainFolder"的路径.

What I'm uncertain about is how to get the path of the "MainFolder".

任何指针都很棒!

谢谢, 汤姆

推荐答案

我会使用-[NSString stringByDeletingLastPathComponent]两次.

NSString *bundlePath = [[NSBundle mainBundle] resourcePath];
NSString *secondParentPath = [[bundlePath stringByDeletingLastPathComponent] stringByDeletingLastPathComponent];

这篇关于使用来自[[NSBundle mainBundle] resourcePath]的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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