Your Second iOS & SwiftUI App

Nov 4 2021 · Swift 5.5, iOS 15, Xcode 13

Part 2: Data Flow

15. Challenge: Image Deletion Button

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 14. Confirmation Dialogs Next episode: 16. Model Objects

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

So, you can delete images, now? And you’ve got a button to go through with it, on your confirmation dialog… How about another button …to launch the dialog when you actually need it?!

.confirmationDialog(isPresented: .constant(true)) {
  @State var showingImagePicker = false
  @State var showingDialog = false

  var body: some View {
.confirmationDialoge(...., isPresented: $showingDialog) {
        .scaledToFit()

        HStack {
          Button("Update Image…") {
            showingImagePicker = true
          }
          .padding()
        }
      }

            showingImagePicker = true
          }
        }
        .padding()
        HStack {
          Button("Update Image…") {
            showingImagePicker = true
          }

          Button("Update Image…") {
            showingImagePicker = true
          }
Button("Delete Image…") {
Image") {
          Button("Delete Image") {
            showingDialog = true
          }
            showingDialog = true
          }

          Spacer()

          Button("Update Image…") {
        HStack {
          Spacer()

          Button("Delete Image") {
          Spacer()
        }
        .padding()
      HStack {
        if image != nil {
          Spacer()
          Button("Delete Image") { showingDialog = true }
        }