ios - 如何在 iOS 中将 .m 文件读取为 NSString

标签 ios nsbundle

我试图在 UITextView 中显示一个实现文件(.m 文件中的代码)。下面是我使用的代码片段。但它返回零。

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"TextCheck.m" ofType:@"m"];

最佳答案

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"TextCheck.m" ofType:@"m"];

将代码替换为以下行:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"TextCheck" ofType:@"m"];

关于ios - 如何在 iOS 中将 .m 文件读取为 NSString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31245653/

相关文章:

ios - UITableViewCell中的Braintree信用卡

ios - tableView :indexPathForCell returns nil when clicking in cell

ios - 仅加载包含资源的 bundle 时出现 "Cannot find executable for CFBundle"

macos - 框架与 bundle

objective-c - 在 Objective C 中从 NSBundle 获取图像路径?

objective-c - Objective-C 中的 NSBundle 和 mainBundle 是什么?

ios - 在 xCode 5 项目中使用 iOS6 If 语句时生成错误

ios - SpriteKit 中的 "Collision Map"

android - Cordova 应用程序的 Linkedin 登录

ios - swift 2 - 从应用程序主包读取文本文件时出现文件未找到错误