无夜之星辰
无夜之星辰

Reputation: 6178

Can I get markdown file's contents in Objective-C?

I can get the contents of a .txt file in this way:

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

However,it is no use when the file is a markdown file:

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

The articlePath is "nil",but the file is exist actually.

I wonder if there any method I can use to get the contents of a .md file.

Thanks in advance.

Upvotes: 0

Views: 131

Answers (1)

Abdelahad Darwish
Abdelahad Darwish

Reputation: 6067

Go to : Target -> "Build Phases" -> "copy bundle Resources" Then add that particular file here.

Make sure that test2 file is there enter image description here

Upvotes: 2

Related Questions