Skip to content

Instantly share code, notes, and snippets.

@robertmryan
Last active February 28, 2016 23:20
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 robertmryan/2e2418e9bb9a3cb37181 to your computer and use it in GitHub Desktop.
Save robertmryan/2e2418e9bb9a3cb37181 to your computer and use it in GitHub Desktop.
More complete example
var text: String!
override func viewDidLoad() {
super.viewDidLoad()
let url = NSBundle.mainBundle().URLForResource("test", withExtension: "json")!
var files = [String : NSFileWrapper]()
var error: NSError?
files["file.json"] = NSFileWrapper(URL: url, options: nil, error: &error)
if let file = files["file.json"],
contents = file.regularFileContents,
stringContents = NSString(data: contents, encoding: NSUTF8StringEncoding) {
text = stringContents
print(text)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment