How can I read JSON file from disk and store to array in Swift
Posted
by
Ezekiel Elin
on Stack Overflow
See other posts from Stack Overflow
or by Ezekiel Elin
Published on 2014-06-07T02:10:11Z
Indexed on
2014/06/07
3:26 UTC
Read the original article
Hit count: 254
JSON
|swift-language
I want to read a file from Disk in a swift file. It can be a relative or direct path, that doesn't matter. How can I do that?
I've been playing with something like this
let classesData = NSData .dataWithContentsOfMappedFile("path/to/classes.json");
And it finds the file (i.e. doesn't return nil) but I don't know how to manipulate and convert to JSON, the data returned. It isn't in a string format and String() isn't working on it.
© Stack Overflow or respective owner