'I am getting an error called "Argument passed to call that takes no arguments"

I am following the ios app development tutorial for the Scrumdinger app and I have followed the tutorial and it has worked until I finished the Passing Data with Binding Section. I keep gettin an error on my line 58 "DetailEditView(data: $data)". This is exactly what the tutorial says to put so I do not know why I am gettin the error.

This is my full code for the Detail View File: "

//
//  DetailView.swift
//  Scrumdinger
//
//  Created by ZOE HEIM on 4/25/22.
//

import Foundation

import SwiftUI

struct DetailView: View {
    @Binding var scrum: DailyScrum
    
    @State private var data = DailyScrum.Data()
    @State private var isPresentingEditView = false
    
    var body: some View {
        List {
            Section(header: Text("Meeting Info")) {
                NavigationLink(destination: MeetingView()) {
                    Label("Start Meeting", systemImage: "timer")
                        .font(.headline)
                        .foregroundColor(.accentColor)
                }
                HStack {
                    Label("Length", systemImage: "clock")
                    Spacer()
                    Text("\(scrum.lengthInMinutes) minutes")
                }
                .accessibilityElement(children: .combine)
                HStack {
                    Label("Theme", systemImage: "paintpalette")
                    Spacer()
                    Text(scrum.theme.name)
                        .padding(4)
                        .foregroundColor(scrum.theme.accentColor)
                        .background(scrum.theme.mainColor)
                        .cornerRadius(4)
                }
                .accessibilityElement(children: .combine)
            }
            Section(header: Text("Attendees")) {
                ForEach(scrum.attendees) { attendee in
                    Label(attendee.name, systemImage: "person")
                }
            }
        }
        .navigationTitle(scrum.title)
        .toolbar {
            Button("Edit") {
                isPresentingEditView = true
                data = scrum.data
            }
        }
        .sheet(isPresented: $isPresentingEditView) {
            NavigationView {
                DetailEditView(data: $data)
                    .navigationTitle(scrum.title)
                    .toolbar {
                        ToolbarItem(placement: .cancellationAction) {
                            Button("Cancel") {
                                isPresentingEditView = false
                            }
                        }
                        ToolbarItem(placement: .confirmationAction) {
                            Button("Done") {
                                isPresentingEditView = false
                                scrum.update(from: data)
                            }
                        }
                    }
            }
        }
    }
}

struct DetailView_Previews: PreviewProvider {
    static var previews: some View {
        NavigationView {
            DetailView(scrum: .constant(DailyScrum.sampleData[0]))
        }
    }
}

" Here is the link to the tutorial I am following as well:

https://developer.apple.com/tutorials/app-dev-training/passing-data-with-bindings



Solution 1:[1]

Seems you are following the tutorial from the start, which is logical. However, the project files of this lesson includes a modification of DailyScrum.swift, which defines update() as follows.

mutating func update(from data: Data) {
    title = data.title
    attendees = data.attendees
    lengthInMinutes = Int(data.lengthInMinutes)
    theme = data.theme
}

Solution 2:[2]

In section 2 step 8 of the tutorial data property of DetailEditView is declared as

@State private var data = DailyScrum.Data()

which is initialized at declaration time, so DetailEditView has no initializer at this point.

Now see Section 3 step 1 where data property is modified as

@Binding var data: DailyScrum.Data

and now DetailEditView has inferred initializer which we can use as

DetailEditView(data: some binding var)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hicham Elmongui
Solution 2