Urgent!
Replies
If you're such in a hurry, you should give information to help helping you.
And post the code itself, not only a screenshot, so that we can understand the context, aww ell as an exact reference of the tutorial page.
https://developer.apple.com/tutorials/app-dev-training/passing-data-with-bindings
You have probably missed something in the code and did not follow the tutorial instructions.
Is it the tutorial below ? What is your exact code ?
You have probably not do what is instructed, to replace
let scrum: DailyScrum
by
@Binding var scrum: DailyScrum
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)
}
}
}
}
}
}
}
In the DailyScrum extension, you need the code:
mutating func update(from data: Data) {
title = data.title
attendees = data.attendees
lengthInMinutes = Int(data.lengthInMinutes)
theme = data.theme
}
This appears in the "Passing Data with Bindings" section downloadable completed code, but I think it may be missing from the step-by-step instructions (or I missed seeing it).
-
Bump, Apple still has not updated the step-by-step version
-
This solution works and it is still not updated in the step by step instructions
-
Still working and the issue is not updated yet by Apple
Had the same issue and DDP's solution worked for me.
Leaving this comment to bump this thread and this solution. Hopefully, Apple will see this and update the Scrumdinger guide to include this little bit, because, for anyone that's just learning, this would be extremely hard to figure out on their own.
-
I feel it would be best to create a feedback via the Feedback Assistant app, you can create feedbacks for tutorials / websites / documentation. I think @Claude31 would know better what option to choose. Your feedback would help others who are learning swift
-
Totally agree! I knew where to look because the "Theme" colors aren't covered either but this issue hangs you up to dry if you think "update" is/should be a baked in method.