NSBundle 获取文件路径为空


NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test.m2" ofType:nil];



运行后filePath是空的,但是已经把这个文件加到Xcode中了,

上网查了下发现由于当时是直接拖进去的,没有添加到资源文件路径,

需要采用add file to 方式添加文件。

但是这样有时也会因为Xcode的原因添加不到资源文件中。

在项目设置中Build Phases > Copy Bundle Resources 中可以查看已经添加进去的资源文件,如果里面没有,那就需要在这里手动添加了。


原文来自:http://blog.csdn.net/wang_lev/article/details/50728669

猜你喜欢

转载自blog.csdn.net/wokenshin/article/details/70049951