Reputation: 1396
I have an array result
["https://woo.demoapp.xyz/wp-content/uploads/2017/10/sunglasses.jpg"]
i try to convert to string url in tableview and show image with SDWebImage
let dic = productArray[indexPath.row] as! NSDictionary
let image = dic.object(forKey: "images") as! NSArray
let imageUrl = image.value(forKey: "src") as! NSArray as! [String]
cell.pinImage.sd_setImage(with: URL(string: imageUrl), placeholderImage: UIImage(named: "pin1"))
Upvotes: 1
Views: 3307
Reputation: 861
If you have getting array then you used below code.
In Swift objectAtIndex: 0 looks like this:
let srcImage:NSDictionary = image[0] as! NSDictionary
let strImageUrl:NSString = srcImage.value(forKey: "src") as! NSString
let srcImage = image[0] as! [String: Any]
let strImageUrl = srcImage["src"] as! String
Upvotes: 2