1

cant get the JSON code of a file "ios.lpofficial.net/iosdata.json" a link thereeeee, i tried to use the NSURLRequest but i doesn't work. And tried to get the source code of the page as usual i stuck on that line:

let code = NSString(contentsOfURL: URL, encoding: NSUTF8StringEncoding, error: &error)

the problem was in new UnsafeMutablePointer<UInt> i real can't understand what is that thing.

im using my own hosting with the json file, so may be i need to change something there.

please help)

Ilya Leshkinov
  • 101
  • 3
  • 11

1 Answers1

1

Try this:

var code: NSString?
do {
    code = try NSString(contentsOfURL: URL, encoding: NSUTF8StringEncoding)
} catch _ {
    // Handle the error
}

You can also do that:

let code = try! /*(or try?)*/ NSString(contentsOfURL: URL, encoding: NSUTF8StringEncoding)
Eilon
  • 2,698
  • 3
  • 16
  • 32