vicky vicky - 1 year ago 128
Swift Question

How to pass array to use SDImage to display image in swift

Here I am displaying images in image view I am able to display image but only single image in all rows of TableView I am using SDImage with swift for the first time. so I want to pass the array in the following code to display the respective images in each row.Here I am successfully displaying name by passing it through array now just wanted to display the images. NOTE : see the code in comments below but its giving error want to pass the same array but don't know how to write in swift.

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

let cell : TableViewCell = self.tableView.dequeueReusableCellWithIdentifier("Cell") as! TableViewCell

let strTitle : NSString = arrDict[indexPath.row].valueForKey("clip_name") as! NSString

cell.clipName.text = strTitle as String

cell.videoImage.sd_setImageWithURL(NSURL(string:"", arrDict(indexPath.r‌​ow).objectForKey("clip_image_path")))

return cell


Answer Source

Have you try this

let imagePath = NSString(format: "",arrDict[indexPath.row].valueForKey("clip_image_path") as! NSString)
cell.videoImage.sd_setImageWithURL(NSURL(string: imagePath as! String))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download