Closed ParisJacksonNewman closed 4 years ago
Hey,
if your URL can be nil - use a condition. You can use ZStack
, AnyView
, map
- there are various ways to conditionally display a view in SwiftUI - the choice is yours 😉
As for URLImage
, initializer expects non-optional URL, same as standard Image
expects the image name.
I am an inexperienced developer using a News API to load images into a list, however, occasionally, the json will have nil for the urlToImage and I have no idea how to solve this problem.
Here is a link to the more detailed problem. Link