Skip to content

Instantly share code, notes, and snippets.

@ezura
Last active November 26, 2015 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ezura/c426a46aa15eafac89a2 to your computer and use it in GitHub Desktop.
Save ezura/c426a46aa15eafac89a2 to your computer and use it in GitHub Desktop.
playground でファイル読み込みをする (画像・テキストファイルなど) ref: http://qiita.com/ezura/items/be522ff45856392eedcf
playground -> "パッケージの内容を表示" -> Resources ディレクトリ作成
// 画像
let image = UIImage(named: "sample")
// テキスト
let path = NSBundle.mainBundle().pathForResource("sample", ofType: "json")
let contents = try! String(contentsOfFile: path!, encoding: NSUTF8StringEncoding)
mkdir 作業中のplayground.playground/Resources
// 画像
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