Skip to content

Instantly share code, notes, and snippets.

@donguri9
Created February 17, 2017 21:39
Show Gist options
  • Save donguri9/6ff8763c06468a739a21dc847418dc61 to your computer and use it in GitHub Desktop.
Save donguri9/6ff8763c06468a739a21dc847418dc61 to your computer and use it in GitHub Desktop.
バンドル内ファイル検索
import Foundation
if let path: String = Bundle.main.path(forResource: "text", ofType: "txt") {
do {
// ファイルの内容を取得する
let content = try String(contentsOfFile: path)
print("content: \(content)")
} catch {
print("ファイルの内容取得時に失敗")
}
}else {
print("指定されたファイルが見つかりません")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment