gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 06:47:51 25 4
gpt4 key购买 nike

如何知道XCode项目中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)

如何解决这个问题呢??我不知道错误在哪里..
请帮忙

谢谢你

最佳答案

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

  • 展开 xcode 中的“产品”组
  • 右键单击 your_product.app 并单击“在 Finder 中显示”
  • 在 finder 中右键单击您的应用程序,然后单击“显示包内容”

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

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

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com