I have implemented an http json request that works fine, but it prevents the user from clicking on it and can access the information only when it is downloaded.
Example: I have a UITableView with 3 Items, if I click on one of them and in that view is a request it will not enter the screen until it is ready.
Request class example:
class Requisicao {
let urlDefault = "http://puc.vc/painel/webservice/"
func getJSON(urlToRequest: String) -> NSData{
let urlFull = urlDefault + urlToRequest
return NSData(contentsOfURL: NSURL(string: urlFull)!)!
}
func parseJSON(inputData: NSData) -> NSDictionary{
var error: NSError?
var boardsDictionary: NSDictionary = NSJSONSerialization.JSONObjectWithData(inputData, options: NSJSONReadingOptions.MutableContainers, error: &error) as! NSDictionary
return boardsDictionary
}
}
Call Sample:
class ProcedAcadViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let request = Requisicao()
let data = request.getJSON("procedimentosacademicos/")
let json = request.parseJSON(data)
println(json)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
How can I solve this problem?