2017-08-28 67 views
0

我可以得到一个.txt文件的内容是这样的:我可以得到降价文件的Objective-C中的内容?

NSString *articlePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@".txt"]; 
return [NSString stringWithContentsOfFile:articlePath encoding:NSUTF8StringEncoding error:nil]; 

然而,这是没有用的,当该文件是一个降价文件:

NSString *articlePath = [[NSBundle mainBundle] pathForResource:@"test2" ofType:@".md"]; 
return [NSString stringWithContentsOfFile:articlePath encoding:NSUTF8StringEncoding error:nil]; 

articlePath是“无” ,但文件实际上是存在的。

我不知道是否有任何方法,我可以用它来获得一个.MD文件的内容。

在此先感谢。

回答

1

转到:目标 - >“构建阶段” - >“复制包资源”当年这里添加特定文件。

确保test2的文件是存在的enter image description here

+0

呀,你是right.But我仍然搞不清楚为什么.txt文件中添加全自动但.MD文件没有。 –

+1

当您添加资源,确保不只是复制项目到目的地组的文件夹(如果需要)被选中,而且蜱在添加到目标列表中的相应目标。 –

相关问题