2017-08-28 70 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

當您添加資源,確保不只是複製項目到目的地組的文件夾(如果需要)被選中,而且蜱在添加到目標列表中的相應目標。 –

相關問題