TableView takes a cell from a xib file, the cell consists of an ImageView and four labels. enter image description here

functions of the delegate and the source of the TableView by template ...

Fill Code:

cell.title = categorySelectArray[indexPath.row].valueForKey("title") as! String cell.venue = categorySelectArray[indexPath.row].valueForKey("venue") as! String cell.date = categorySelectArray[indexPath.row].valueForKey("date") as! String cell.min_price = "от \(categorySelectArray[indexPath.row].valueForKey("min_price") as! String) руб." cell.img.image = UIImage(data: imgData) 

nothing particularly heavy in my opinion, although the picture is loaded from an Internet

Noticeable brakes when scrolling but at the same time, the owner of the database has a native application that works with a bang. I want to remove friezes when scrolling if possible without third-party libraries

  • And if you comment out getting pictures from the server, the problem disappears? - Max Mikheyenko
  • Why every time you make a picture of the date? How do you load a picture? In which stream? Who is the owner of the database? Try to comment bit by bit the fill code. As soon as it stops slowing down, consider finding a bug. - Valentin
  • commenting on the picture does not give anything, the brakes remain, I take the picture from the site for a direct link, the site is on a powerful server and a thick channel, I don’t load the picture in general, I load the picture not in the stream but in the standard tableView method cellForRowAtIndexPath - Sam07
  • UPS was not right, the picture slows down, or rather its constant daunload, I just forgot to comment when checking the direct download, now the only question is how to change the algorithm, while I see only one solution to download all the pictures into the array at once and attach the downloaded pictures to the crawler, should scroll quickly but the memory will devour oyoyoy - Sam07

2 answers 2

Dokumekan algorithm eats more memory (iPhones pull) but removes friezes The getimages function is performed in viewDidLoad

 func getImages(){ for str_imgUrl in categorySelectArray { let imageStr = str_imgUrl.valueForKey("image") as! String let imageURL = "https:\(imageStr)" let imgURL: NSURL = NSURL(string: imageURL)! let imgData: NSData = NSData(contentsOfURL: imgURL)! imagesArray.addObject(imgData) } } 

Further, in the tableView method (.... cellForRowAtIndexPath), the images are taken from the created array of downloaded images

cell.img.image = UIImage (data: imagesArray [indexPath.row] as! NSData)

    Write on Swift, use xib and be amazed at the brakes? This is how to write under iOS on the Nokia 3310. Create prototype cells in the storyboard, from there we will think. You should profile (Xcode Run -> Profile) the system through Time Profiler (Instruments) and see what the system uses a lot, based on this, you can already say what the problem is. (Add screenshots of profiler to question)

    • hmm, it’s strange that xibs are moveton, they advise to use the new book, use profiling, problem area after 20 seconds when it scrolls, up to 20 seconds where the peaks are parsing and filling the array of the profiling screen: uploads.ru/Yf9BC.png - Sam07
    • I understood everything, you can not load pictures every time you scroll through, I change the algorithm - Sam07
    • one
      But you can read more about "Write on Swift, use xib and be surprised at the brakes?" - Max Mikheyenko