I am new in swift and I am facing problem to show multiple url string image to uiimage
my code is like this
In viewdidLoad
Array = [UIImage (named: "ISDI1")!,UIImage (named: "ISDI2")!,UIImage (named: "ISDI3")!,UIImage (named: "ISDI4")!,UIImage (named: "ISDI5")!]
sliderView.maximumValue = Float(Array.count - 1)
@IBAction func btnPreviousClick(_ sender: Any) {
sliderView.value -= 1
imgView.image = Array[Int(sliderView.value)]
}
@IBAction func btnNextClick(_ sender: Any) {
sliderView.value += 1
imgView.image = Array[Int(sliderView.value)]
}
@IBAction func SliderViewClick(_ sender: UISlider) {
var value = Int(sender.value)
imgView.image = Array[value]
}
Now I am getting url string like this
http://diceapp.in/mailer_isdi_2020/images/4.jpeg , http://diceapp.in/mailer_isdi_2020/images/3.jpeg , http://diceapp.in/mailer_isdi_2020/images/1.jpeg
How can I show this urls in image view ?
I am using this code to convert url to image but it getting crash now
let url = NSURL(string:Image ?? "")
if !(url?.absoluteString == "") {
let data = NSData(contentsOf: url! as URL) //make sure your image in this url does exist, otherwise unwrap in a if let check
imgView.image = UIImage(data: data! as Data)
}