Image(uiImage: UIImage(data: training.image!)!)
.resizable()
.scaledToFill()
This code is dangerous as it is force unwrapping training.image, it would crash the app when it is nil.
I need to provide a default image to fall back on safely.
My solution for now is use if let
if let data = training.image {
let uiImage = UIImage(data: data)!
Image(uiImage: uiImage)
.resizable()
.scaledToFill()
}
Top comments (0)