简体   繁体   English

我可以在Objective-C中获得markdown文件的内容吗?

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

I can get the contents of a .txt file in this way: 我可以通过以下方式获取.txt文件的内容:

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. articlePath为“ nil”,但该文件实际存在。

I wonder if there any method I can use to get the contents of a .md file. 我想知道是否可以使用任何方法来获取.md文件的内容。

Thanks in advance. 提前致谢。

Go to : Target -> "Build Phases" -> "copy bundle Resources" Then add that particular file here. 转到:目标->“构建阶段”->“复制捆绑资源”,然后在此处添加该特定文件。

Make sure that test2 file is there 确保存在test2文件 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以将JSON数据写入iOS / Objective-C中的文件吗? - Can I write JSON data to a file in iOS/Objective-C? 我可以在Objective-C中调用组合的super的方法吗 - Can I invoke the composite's super's method in Objective-C 我已经尝试了全部,但是无法将Swift文件导入到Objective-C文件中 - I've tried it all, but I can't import my Swift file to my Objective-C file 我正在学习的“ Objective-C”中有多少是通用的Objective-C,而不是Apple的框架? - How much of the “Objective-C” I'm learning is universal Objective-C, and not Apple's frameworks? 如何让我的核心数据实体的属性在 objective-c 单元测试中可见 - How do I get my Core Data entity's attributes to be visible in objective-c unit tests 我可以在iOS上的C / Objective-C中创建内存映射的FILE *吗? - Can I create a memory-mapped FILE * in C/Objective-C on iOS? 类似的对象 - 不同的内容(objective-c) - Similar objects - different contents (objective-c) 我怎样才能查找objective-c的属性@synthesize getter setter代码 - how can I look up objective-c's property @synthesize getter setter code 如何更改 Objective-C 中字符串数组中的子字符串? - How can I change substring(s) in an array of strings in Objective-C? Objective-C:获取文件类型支持的文件扩展名 - Objective-C: Get supported file extensions for a file type
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM