UIImage(data: data)
Liang Wang
Posted on February 2, 2024
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()
}
💖 💪 🙅 🚩
Liang Wang
Posted on February 2, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
githubcopilot AI Innovations at Microsoft Ignite 2024 What You Need to Know (Part 2)
November 29, 2024