E
E
Evgeniy Karambirov2018-08-22 10:10:30
iOS
Evgeniy Karambirov, 2018-08-22 10:10:30

How to get non nil in file path in subfolders in Main Bundle?

Hey! There is a task to open browser games in WebView, which I copied into the project (see screenshot).
When I try to get the path of a file inside a folder, I always get path = nil:

let path = Bundle.main.path(forResource: "index", ofType: "html", inDirectory: "games/game1")

But if you put index.html in the root of the project, and use the method without the inDirectory parameter, then the path is found.
let path = Bundle.main.path(forResource: "index", ofType: "html")

Question: how to get the path to a file that is inside a folder?
PS I copied the folder to the project not as groups, but even if you copy it as groups (yellow folders), the result does not change.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question