Created
February 17, 2017 21:39
-
-
Save donguri9/6ff8763c06468a739a21dc847418dc61 to your computer and use it in GitHub Desktop.
バンドル内ファイル検索
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
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