I have an application that returns a json to a tableview, however, every time I roll the cells it kind of chokes, I've already been told I'd have to leave the asynchronous json return function ... Does anyone know how to treat this in Swift?
There are only 10 lines with image and next to a label, but with tests done, since the problem of slowness is only with the loading of the images that have in the cells in the method cellForRowAtIndexPath if I comment from the line that grabs the url of the images until the end is good, it is as if the CellForAtIndexPath method made every request of the images with each scroll.
The part of the code that you have pro ...
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell:Cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! Cell
cell.info.text = arrayJson[indexPath.row]
cell.info.font = UIFont.systemFontOfSize(12.0)
if let url = NSURL(string: self.arrayJsonImages[indexPath.row]) {
let data = NSData(contentsOfURL: url)
cell.imagem.contentMode = UIViewContentMode.ScaleAspectFit
cell.imagem.image = UIImage(data: data!)
cell.imagem.layer.masksToBounds = true;
cell.imagem.layer.cornerRadius = 15;
}
return cell
}