在子子目录中访问具有相同名称的文件

时间:2010-10-29 19:24:05

标签: iphone objective-c ios uiwebview nsbundle

首先是我的结构:

Application
|---> dirA
    |---> dirB
        |---> index.html 
        |---> somefile.js
    |---> dirC
        |---> index.html 
        |---> somefile.js
    |---> dirD
        |---> index.html 
        |---> somefile.js
这里有些问题。我需要在我的webview中加载这个不同目录的index.html。但我不知道如何获取特定目录的网址,让dirB在dirA中说道,我收到通知Warning: Multiple build commands for output testo4.app/index.html。问题是,我无法重命名文件,因为我创建了子目录(真正的目标,而不仅仅是来自xcode的“组”)

感谢所有提示!

1 个答案:

答案 0 :(得分:0)

如果这些是真实目录,那么它们的路径应该是testo4.app/dirA/dirB/index.htmltesto4.app/dirA/dirC/index.htmltesto4.app/dirA/dirD/index.html,不应该是它们吗?

如果文件在您的包中,您可以使用类似

的内容
NSString *path = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"index"] ofType:@"html" inDirectory:[NSString stringWithFormat:@"dirA/dirB/"]];
例如,

用于dirB内的那个。

相关问题