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

发布于 2024-09-14 15:49:52 字数 698 浏览 3 评论 0原文

如何知道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)

如何解决这个问题?我无法弄清楚错误在哪里.. 请帮忙

谢谢

How to know the contents of NSbundle in XCode Porject??

bcoz issue is, I have placed a config.doc file in resource folder of my XCode project and i want to read the contents of that config.doc file, but it says that config.doc file is not found. How to solve this problem??

This is how my code looks like:

-(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);
}

OUTPUT :

File not found!!
Contents of config file :(null)

how to solve this problem?? i'm not able to make where is the mistake..
plz help

Thank You

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愛上了 2024-09-21 15:49:52

您可以通过以下方式查看捆绑包的内容:

  1. 在 xcode 中展开“产品”组
  2. 右键单击​​ your_prodcuct.app 并单击“在 Finder 中显示”
  3. 在 Finder 中右键单击您的应用程序并单击“显示包内容”

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

You can see the contents of the bundle in the following way :

  1. Expand the "Products" group in xcode
  2. Right click on your_prodcuct.app and click "Reveal in Finder"
  3. In finder right click on your app and click "Show package contents"

Now you can check whether the file actually exists in the bundle or not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文