Domanda

I have some data files in the resources/ folder for my Rubymotion project. How do I access them in the code? Accessing them without a path, is not working.

e.g. I have a file in resources/ called schema.json

Here's the code I am using:

NSData.dataWithContentsOfFile("schema.json") <--- returns nil
È stato utile?

Soluzione

Figured it out.

path = NSBundle.mainBundle.pathForResource("schema", ofType:"json")
NSData.dataWithContentsOfFile(path)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top