我在我的项目中创建了一个新文件夹,其中复制了一个图像(称为“io.jpg”)。
我也检查了构建阶段 - >复制束资源和文件在那里。
所以我试图让这个图片的路径:从NSBundle获取无路径
NSBundle* bundle=[NSBundle mainBundle];
NSString* path=[bundle pathForResource: @"io" ofType: @"jpg"];
NSLog(@"%@",path);
但它打印(空),我也试过这样:
NSBundle* bundle=[NSBundle mainBundle];
NSString* path=[bundle pathForImageResource: @"io"];
NSLog(@"%@",path);
但它仍然打印(空)。
有什么问题?
你看过的实际建成的产品,以确保文件被正确复制? – jtbandes 2012-07-29 02:13:45
是的,该文件在应用程序目录中。 – 2012-07-29 11:23:05
可能重复的[资源路径不工作Xcode](http://stackoverflow.com/questions/11447010/resourcepath-not-working-xcode) – trojanfoe 2012-07-30 06:58:43