UITableView image of load cell asynchronously with NSURLSession in Xcode 7 Swift 2

Can someone please send an example code on how to display a table view that loads cell images asynchronously?

There are many questions and blog posts with working code examples for earlier versions of Swift, but I cannot find examples compatible with Swift 2.0 and Xcode 7.

+4
source share
1 answer

pinterest has an excellent library for this https://github.com/pinterest/PINRemoteImage

import PINRemoteImage

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

            let j = MYCELLOBJECT![indexPath.row]
            let c = tableView.dequeueReusableCellWithIdentifier(CUSTOMCell.id) as! CUSTOMCell

            c.Icon?.pin_setImageFromURL(NSURL(string: j.URLTOIMAGE), placeholderImage: UIImage(), processorKey: "Ball", processor: { (result, cost) -> UIImage! in
              return result.image

                }, completion: { (result) -> Void in })

            return c

    }
0
source

Source: https://habr.com/ru/post/1608574/


All Articles