Created
April 26, 2017 18:07
-
-
Save ndurell/a817a5eb556e42fb0965420cfeea7bf1 to your computer and use it in GitHub Desktop.
Instructions for reading a file from the bundle
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 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