ios - 我可以在 Objective-C 中获取 Markdown 文件的内容吗?

标签 ios objective-c

我可以通过这种方式获取 .txt 文件的内容:

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

但是,当文件是markdown文件时没有用:

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

articlePath为“nil”,但文件实际存在。

我想知道是否有任何方法可以用来获取.md 文件的内容。

提前致谢。

最佳答案

转到:目标 ->“构建阶段”->“复制捆绑资源”,然后在此处添加该特定文件。

确保 test2 文件存在 enter image description here

关于ios - 我可以在 Objective-C 中获取 Markdown 文件的内容吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45915760/

相关文章:

ios - 在另一个 View Controller 上呈现透明 View Controller

ios - `pod install` 之后的空 Pod header 文件夹

ios - 在 Xcode 中成功编译和构建后,应用程序崩溃

ios - 如何访问 objective c 文件中的 swift public 函数?

ios - warning "Class implementation may not have super class"的含义

objective-c - 从模态视图启动相机会导致 iPad 上出现不需要的调整大小

ios - Objective-C:如何获取 UIScrollView 的缩放内容

ios - 不区分大小写的字符串搜索 - iphone

ios - 显式函数原型(prototype) | ios 64位架构

iphone - objective-c - 从远程服务器播放音频时显示缓冲进度