2

我的 Rubymotion 项目的资源/文件夹中有一些数据文件。如何在代码中访问它们?没有路径访问它们是行不通的。

例如,我在 resources/ 中有一个名为 schema.json 的文件

这是我正在使用的代码:

NSData.dataWithContentsOfFile("schema.json") <--- returns nil
4

1 回答 1

6

弄清楚了。

path = NSBundle.mainBundle.pathForResource("schema", ofType:"json")
NSData.dataWithContentsOfFile(path)
于 2012-06-20T13:08:16.763 回答