开发者

Cocoa: get path to Contents/Resources folder in cocoa bundle

I am aware of how to get a specific file from the Resources fo开发者_开发问答lder in cocoa, i.e. :

NSBundle* myBundle = [NSBundle mainBundle];
NSString* myImage = [myBundle pathForResource:@"Seagull" ofType:@"jpg"];

anyways, I'd like to have a simple function that gives me the path to the Resources folder so I can use it in c++ like this.

String getResourcePath()
{
    return the correct path here
}

std::ofstream theFile;
theFile.open(getResourcePath()+"test.txt");

I guess I could manually combine the main bundle name with Contents/Resources, anyways I'd like to know if there is a more robust solution!

Thanks!


If you ever wonder if an Apple-provided class has a certain method, do look up Apple's own documentation before asking the question here at SO.

In this case, the answer is this method. But let me reiterate:

If you ever wonder if an Apple-provided class has a certain method, do look up Apple's own documentation before asking the question here at SO.

And, when you do so, go over all the methods in the documentation. That way, you'll learn what kind of methods are available.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜