I watched the Jared Davidson's video about parsing JSON with SwiftJSON. I followed this video : https://www.youtube.com/watch?v=_NfijT6mt6A
IT WAS WORKING FINE !! ... but the JSON file was a local file. Now I want to move this file to my website !
This was my code before trying to use a remote JSON file (this code was working very well) :
let path: String = NSBundle.mainBundle().pathForResource("Database", ofType: "json") as String!
let jsonData = NSData(contentsOfFile: NSURL(string: path) as NSData!
let readableJSON = JSON(data: jsonData, options: NSJSONReadingOptions.MutableContainers, error: nil)
// Récupère et classe les élèment de la date
let title = readableJSON["dates"][todayDate]["title"].string as String!
To be able to parse the JSON file stored on my website I changed this line : let jsonData = NSData(contentsOfFile: NSURL(string: path) as NSData!
to this :
let jsonData = NSData(contentsOfURL: NSURL(string: "http://mywebsite.com/Database.json")!) as NSData!
AND BOOOMM : Error :( when I run the Simulator
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb)