I am new to Swift and trying to make a first app on SwiftUI on developer.apple and faced a problem when trying to update a view. I was trying to find a mistake, but I did everything step by step and code is same with sample code. I can not understand where is mistake. Hope someone can help me.
Error when add this line of code
scrum.update(from: data)
*Argument passed to call that takes no arguments
*Cannot use mutating member on immutable value: 'self' is immutable
*Referencing instance method 'update()' requires wrapper 'Binding'
Error when typing scrum.update :
*This property is defined on _CALayerView
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)
}
}
}
}
}
}
My guess is that the 'DailyScrum.swift' file is probably missing some code. Fix
DailyScrum.swift
file like the following code.