Last active
November 26, 2015 03:39
-
-
Save ezura/c426a46aa15eafac89a2 to your computer and use it in GitHub Desktop.
playground でファイル読み込みをする (画像・テキストファイルなど) ref: http://qiita.com/ezura/items/be522ff45856392eedcf
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
playground -> "パッケージの内容を表示" -> Resources ディレクトリ作成 |
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 image = UIImage(named: "sample") | |
// テキスト | |
let path = NSBundle.mainBundle().pathForResource("sample", ofType: "json") | |
let contents = try! String(contentsOfFile: path!, encoding: NSUTF8StringEncoding) |
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
mkdir 作業中のplayground.playground/Resources |
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 image = UIImage(named: "sample") | |
// テキスト | |
let path = NSBundle.mainBundle().pathForResource("sample", ofType: "json") | |
let contents = try! String(contentsOfFile: path!, encoding: NSUTF8StringEncoding) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment