Skip to content

Instantly share code, notes, and snippets.

@ndurell
Created April 26, 2017 18:07
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 ndurell/a817a5eb556e42fb0965420cfeea7bf1 to your computer and use it in GitHub Desktop.
Save ndurell/a817a5eb556e42fb0965420cfeea7bf1 to your computer and use it in GitHub Desktop.
Instructions for reading a file from the bundle
let path : URL = Bundle.main.path(forResource: "scifi-novels", ofType: "json").flatMap {
URL.init(fileURLWithPath: $0)
}!
let data = try! Data(contentsOf: path)
let json = try! JSONSerialization.jsonObject(with: data) as? [String: Any]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment