Xcode 7 Playgrounds now supports loading files from the nested Resources
directory.
I can get SKScene(fileNamed: "GameScene")
when I have a GameScene.sks
in my Resources
or NSImage(named:"GameScene.png")
if I have a GameScene.png
in your Resources
.
But how can I read a regular text file from the Playground Resources
directory as well?
We can use the
Bundle.main
So, if you have a test.json in your playground like
You can access it and print its content like that:
Will print