如何知道XCode Porject中NSbundle的内容?
bcoz 问题是,我在 XCode 项目的资源文件夹中放置了一个 config.doc 文件,我想读取该 config.doc 文件的内容,但它说找不到 config.doc 文件。如何解决这个问题呢??
这就是我的代码的样子:
-(void)applicationDidFinishLaunching:(UIApplication*)application
{
if([NSBundle mainBundle]pathForResource;@"config" ofType:@"doc")!=nil)
{
NSLog(@"File Exists");
}
else
{
NSLog(@"File not found!!");
}
NSString *configContents = [[NSBundle mainBundle]pathForResource:@"config" ofType:@"doc"];
NSLog(@"Contents of config file : %@",configContents);
}
输出:
File not found!!
Contents of config file :(null)
如何解决这个问题?我无法弄清楚错误在哪里.. 请帮忙
谢谢
最佳答案
您可以通过以下方式查看 bundle 的内容:
- 在 xcode 中展开“产品”组
- 右键点击 your_prodcuct.app,然后点击“在 Finder 中显示”
- 在 Finder 中右键单击您的应用,然后点击“显示包内容”
现在您可以检查该文件是否确实存在于 bundle 中。
关于objective-c - 我们能知道Xode项目中NSBundle的内容吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3518437/