Bundle.main.path(forResource:ofType:inDirectory:) returns nil

后端 未结 10 2409
遥遥无期
遥遥无期 2020-12-07 13:08

Try not to laugh or cry -- I\'m just getting back into coding after 20 years out...

I\'ve spent more than 4 hours looking at references and trying code snippets to g

10条回答
  •  囚心锁ツ
    2020-12-07 13:43

    This was helpful for me: xcode - copy a folder structure into my app bundle

    Mark "create folder references" option when you create assets in nested folders.

    Then find path to the file like this:

    let path = Bundle(for: type(of : self)).path(forResource: "some_folder_a/some_folder_b/response.json", ofType: nil)
    

提交回复
热议问题