I'm stuck with an issue and need your help. I'm working on an app to manage events and when app loads, all the posts are displayed as expected both with or without images into the post. If I add a new post that contains an image it saves correctly and go back to the scrollview displaying the new post also if I edit any item which have an image and keep the image when saving or add an image into the post that had no image before editing it saves fine and post is displayed immediately into the scrollView. The issue is if I try to create a new post without an image or if I edit a post removing the image and saving, app crashes due to unwrapping option but the weird is that I'm checking nil value into the point of the scrollview where the image is displayed.
ScrollView {
VStack(spacing: 15){
ForEach(items, id: \.self) { item in
VStack(spacing: 15) {
if item.pic != nil {
ZStack(alignment: Alignment(horizontal: .trailing, vertical: .top)) {
Image(uiImage: UIImage(data: item.pic!)!)
.resizable()
.aspectRatio(contentMode: .fill)
.cornerRadius(15)
}
.padding()
.opacity(1)
}
Any ideas ? I'll really appreciate your support.