objective-c - 我们能知道Xode项目中NSBundle的内容吗?

标签 objective-c xcode resources readfile

如何知道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 的内容:

  1. 在 xcode 中展开“产品”组
  2. 右键点击 your_prodcuct.app,然后点击“在 Finder 中显示”
  3. 在 Finder 中右键单击您的应用,然后点击“显示包内容”

现在您可以检查该文件是否确实存在于 bundle 中。

关于objective-c - 我们能知道Xode项目中NSBundle的内容吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3518437/

相关文章:

ios - 我可以为 Twitter 和 Facebook 以外的社交网络创建或使用像 SLComposeViewController 这样的 View Controller 吗

ios - 使用 cocoapods 和 tvOS 找不到框架

ios - 在 iOS7.1 中使用显示(推送)segue 不会出现导航栏

objective-c - 如何从我的应用程序启动 Mac 地址簿并选择特定人员?

ios - UIImageView IOS中间的透明圆圈

c# - 如果发生更改,资源文件就会损坏

C#:如何实现智能缓存

ios - 在倒置肖像模式下关闭 VC 后,主 VC 显示为正常肖像

ios - 在许多 Mac 上运行 UIAutomation 脚本?

java - 资源和属性文件管理问题