How do I access files from the resources folder in my RubyMotion code?
-
15-06-2021 - |
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
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