I have an ImageView. This is the code I am using to add image to the ImageView
var imgstr = pf["ImageFileName"] as String
image = UIImage(named: imgstr)!
println(imgstr) //the output here is abc.png
self.Imageview.image = image
Now I have the image in my Project folder as you can see in the screenshot
Still I am getting this error at run time
fatal error: unexpectedly found nil while unwrapping an Optional value
Add your images to Images.xcassets
imageView.image = UIImage(named:"abc")
What about this?
if let image = UIImage(named:"abc") {
imageView?.image = image
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With