I'm currently making a request to a URL.
One of the teams has the latin character Ñ which appears to be making my JSON nil and as a result no data is displayed in the table to which I am exporting the data. I've done some research and I believe that I need to encode it as NSISOLatin1StringEncoding.
I am using SwiftyJSON to parse the JSON.
let cuartoURL = NSURL(string: cuartoURLString)
//initializes request
let request = NSURLRequest(URL: cuartoURL!)
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.currentQueue()) { response, jsonDataRequest4, error in
if jsonDataRequest4 != nil {
let dataRequest4 = jsonDataRequest4
//println(NSString(data:dataRequest4, encoding: NSUTF8StringEncoding))
//takes data, saves it as json
let cuartoJSON = JSON(data: jsonDataRequest4)
//checks to see that contents != nil, meaning the JSON file was found
if cuartoJSON != nil {
equiposList.removeAll(keepCapacity: false)
//counts number of teams
numeroDeEquipos = cuartoJSON["lista-equipos"].count
println(numeroDeEquipos)
//saves each variable and appends to a array
for var index = 0; index < numeroDeEquipos;++index {
var equipoID = Int(cuartoJSON["lista-equipos"][index]["EquipoID"].number!)
var nomEquipo = cuartoJSON["lista-equipos"][index]["nomEquipo"].string
var nomGrupo = cuartoJSON["lista-equipos"][index]["nomGrupo"].string
var equiposNuevo = listaEquipos(equipoID: equipoID, nomEquipo: nomEquipo!, nomGrupo: nomGrupo!)
equiposList.append(equiposNuevo)
self.tableView.reloadData()
}
//loadingActivity.hideLoadingActivity(success: true, animated: false)
//reloads data once json is complete
self.tableView.reloadData()
} else {
//loadingActivity.hideLoadingActivity(success: false, animated: true)
println("NIL JSON")
}
}