Created
April 27, 2018 07:52
-
-
Save enomoto/dc498933ddc44f34308b4ffa005d781b to your computer and use it in GitHub Desktop.
iOSプロジェクトのテストバンドルに存在するファイルを取得する ref: https://qiita.com/enomotok_/items/27d132969b41bcd26187
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let path = Bundle.main.path(forResource: "foo", ofType: "json") | |
let data: NSData? = try? NSData(contentsOfFile: path!, options: .uncached) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let testBundle = Bundle(for: type(of: self)) | |
let path = testBundle.url(forResource: "bar", withExtension: "json") | |
let data: NSData? = try? NSData(contentsOf: path!, options: .uncached) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment